       @statusView.setStatus 'No .ino/.cpp file to compile', 'warning'
       @statusView.clearAfter 5000
       return
+
+    if atom.config.get('spark-dev.saveAllBeforeCompile')
+      atom.commands.dispatch @workspaceElement, 'window:save-all'
 
     @SettingsHelper.setLocal 'compile-status', {working: true}
     atom.commands.dispatch @workspaceElement, 'spark-dev:update-compile-status'

      type: 'boolean'
      default: true

    # Files ignored when compiling
    filesExcludedFromCompile:
      type: 'string'


        @flashCorePromise = @spark.flashCore @SettingsHelper.getLocal('current_core'), [firmware]
        @flashCorePromise.then (e) =>
          if e.ok == false
            error = e.errors?[0]?.error
            @statusView.setStatus error, 'error'
            @statusView.clearAfter 5000
          else
            @statusView.setStatus e.status + '...'
            @statusView.clearAfter 5000

            if atom.config.get 'spark-dev.deleteFirmwareAfterFlash'
              if fs.existsSync firmware
                fs.unlink firmware

          @flashCorePromise = null
        , (e) =>
