fix(GUI): multiple JSON objects coming up at once from the IPC client (#997)
fix(GUI): multiple JSON objects coming up at once from the IPC client (#997)

The GUI executes the CLI and pipes every line of output coming from
either `stdout` or `stderr` to the IPC server as "messages."

In some scenarios, the child process data handler might receive multiple
lines of output at the same time. Since the CLI outputs stringified JSON
objects each in a different line, trying to parse two JSON objects
separated by a new line causes the parser to crash.

As a solution, we split the data coming in by new lines (`\r\n` in
Windows), and emit a message for only the last one.

Fixes: https://github.com/resin-io/etcher/issues/898
Changelog-Entry: Fix "Invalid message" error caused by the IPC client emitting multiple JSON objects as a single message.
Change-Type: patch
Signed-off-by: Juan Cruz Viotti <4148f5869aa1bcd7efd85b513a5874967e585032@openmailbox.org>
resin-io/resin-etcher,resin-io/etcher,resin-io/etcher,resin-io/herostratus,resin-io/etcher,resin-io/etcher,resin-io/etcher,resin-io/resin-etcher,resin-io/herostratus