     success = (output) -> deployed.resolve(output)
     error = (output) -> deployed.reject(output)
 
-    espruino.reset().then(-> espruino.upload(code)).finally(-> clearInterval(progress)).done(success, error)
+    espruino.reset()
+        .then(-> espruino.upload(code))
+        .then(-> espruino.save())
+        .finally(-> clearInterval(progress))
+        .done(success, error)
+
     deployed.promise
 
 


espruino =
  reset: -> sendToSerial('reset();\n')
  upload: (code) -> sendToSerial("{ #{code} }\n")

module.exports =

  serialPort = new SerialPort(config.espruino.serialPort, { baudrate: 9600 }, false)

  serialPort.on 'error', (error) -> written.reject(error)
  serialPort.on 'data', (data) -> read += data.toString()

  serialPort.open ->
    serialPort.write message, (error) ->
