 # Todo.
 # blow up if not stream
 # add in hook to finish stream slurp whenever you want
-# reject promise on error
 # add timeout to promise chain

        output.append(data.toString())
        finishCommand()

      serialPort.open -> connected.resolve(serialPort)

    if !config.port && !config.serialNumber


    through.obj (chunk, encoding, callback) ->
      publish = createPublisher(@, callback)

      espruino.connect()
         .then(-> espruino.send("reset();\n") if config.reset)
         .then(-> espruino.send("echo(0);\n") if config.echoOff)
         .then(-> espruino.send("{ #{chunk.contents.toString()} }\n"))
         .then(-> espruino.send("echo(1);\n") if config.echoOff)
         .then(-> espruino.send("save();\n") if config.save)
         .then(-> publish.content(espruino.log()))
         .fail((error) -> publish.error(error))
         .finally(-> espruino.close())
