940 Commits

Author SHA1 Message Date
Juan Cruz Viotti
0e1f50422e refactor: integrate etcher-image-stream into the etcher repository (#1040)
This is a long lasting task. The `etcher-image-stream` project takes
care of converting any kind of image input into a NodeJS readable
stream, handling things like decompression in betwee, however its a
module that, except for weird cases, there is no benefit on having
separate from the main repository.

In order to validate the assumption above, we've left the module
separate for almost a year, and no use case has emerged to keep it
like that.

This commit joins the code and tests of that module in the main
repository.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-25 10:32:37 -04:00
Juan Cruz Viotti
87a782f6ff fix(GUI): emit an analytics event on ENOSPC (#1044)
There exists a change the user will run out of space on his drive when
flashing an image format for which we can't guarantee its uncompressed
size (e.g: gzip and bzip2).

When that happens, we show a friendly error message explaining what
happened, however we should also be emitting an analytics event.

Change-Type: patch
Changelog-Entry: Emit an analytics event on `ENOSPC`.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-25 10:32:26 -04:00
Juan Cruz Viotti
2b303f51ba refactor(CLI): rename lib/cli/cli.js to lib/cli/options.js (#1045)
The path `lib/cli/cli.js` is confusing. Rename to `options.js` which is
how we were already referencing the file in `lib/cli/etcher.js`.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-25 10:32:17 -04:00
Juan Cruz Viotti
e5a52c9377 fix(GUI): improve validation error message (#1047)
The current validation message is obscure and tends to lead users to
believe there is a problem with Etcher.

Fixes: https://github.com/resin-io/etcher/issues/735
Change-Type: patch
Changelog-Entry: Improve validation error message.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-25 10:32:07 -04:00
Juan Cruz Viotti
acc1f05269 refactor: move lib/shared/child-writer to lib/child-writer (#1041)
The `child-writer` module is not re-used by both the GUI and the CLI, so
it makes sense to have it in `lib/child-writer`.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-24 12:06:34 -04:00
Benedict Aas
4bf313c7a8 fix(gui): break and wrap bootstrap overflowing tooltip text (#1033)
Instead of letting Bootstrap tooltip text overflow, allow breaks to occur in
words.

Closes: https://github.com/resin-io/etcher/issues/1032
Changelog-Entry: Fix text overflowing on tooltips.
Change-Type: patch
2017-01-17 15:13:07 -04:00
Juan Cruz Viotti
e8c4589e1c fix(GUI): don't ignore any robot message from the CLI (#1026)
We recently sent a PR to handle multiple buffered IPC messages being
reported as a single message, confusing `JSON.parse()` in
`lib/shared/child-writer/index.js`, by only sending the last message,
and ignoring the rest, under the assumption that the loss of some state
messages is not critical for the application and the writing process to
work property.

As @lurch pointed out, however, a buffer set of messages might contain
an error object somewhere, and by ignoring all but the last message, we
ignore any error that happened in the way.

See: https://github.com/resin-io/etcher/issues/898
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-13 18:40:32 -04:00
Benedict Aas
0f2cba38d1 fix: allow undefined drives and images in DriveConstraintsModel (#1016)
Currently the `DriveConstraintsModel` errors when given an `undefined`
drive, or image; this commit changes that behaviour. Comes with tests.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-13 18:14:09 -04:00
Juan Cruz Viotti
543cfea1b4 fix(GUI): expand button in modal menu if its the only one (#1023)
The `.modal-menu` class holds buttons that are shown at the bottom of
the modal. If there are two buttons, the class will show them side by
side with equal sizes, however if there is only one button, it will be
incorrectly resized to 50% of the available space.

Change-Type: patch
Changelog-Entry: Fix alignment of single call to action buttons inside modals.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-13 17:37:35 -04:00
Juan Cruz Viotti
aea4403a16 refactor: move all byte-size conversion logic to lib/shared/units.js (#1021)
This commit extracts the byte-related conversions from the `byte-size`
AngularJS module and the `FlashStateModel` to a re-usable generic
CommonJS module at `lib/shared/units.js`, than can also be used by the
CLI.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-13 16:11:28 -04:00
Juan Cruz Viotti
c552494480 refactor: extract application messages to lib/shared/messages.js (#1022)
There are certain application messages that should be re-used between
the CLI and the GUI. In order to allow such re-usability, we extract out
the application messages used in JavaScript into
`lib/shared/messages.js` as a collection of Lodash `_.template`
templates.

Notice this file doesn't include application messages included in
Angular templates directly since it'd be hard to refactor all of them.
We plan to move to React soon, which will allow moving the remaining
messages very easily.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-13 11:03:46 -04:00
Juan Cruz Viotti
c707c76633 feat(CLI): improve error messages (#1015)
- Inline dictionary of common error codes and friendly descriptions

We used to rely on `resin-cli-errors` for this, however the friendly
descriptions set there can be usually very Resin CLI specific, and thus
confusing to Etcher users.

The dictionary, along with other error related utilities live in
`lib/cli/errors.js`.

- Print error descriptions and codes if they are found

- Move `utils.printError()` to `errors.print()`

Change-Type: minor
Changelog-Entry: Improve Etcher CLI error messages.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-11 18:45:59 -04:00
Juan Cruz Viotti
a14506f016 fix(GUI): open DevTools in detach mode (#1014)
We were previously using the `undocked` mode, which would open DevTools
in a seaprate window, however the user was still allows to pick a new
mode, causing DevTools to be shown inside the main application and
completely ruining the UI.

The `detach` mode in the other hand, completely prevents user from
putting DevTools in the main application, therefore allowing no way to
make the UI look broken.

See: http://electron.atom.io/docs/api/web-contents/
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-11 16:14:03 -04:00
Juan Cruz Viotti
2c64f0da23 chore: add support for snapshot builds (#968)
This commit introduces a `RELEASE_TYPE` option to the Makefile, which
can be either `production` or `snapshot`. If its `production`, the
behaviour its same as it was before.

If `RELEASE_TYPE` is `snapshot`, the shorter version of the current
commit hash is appended to the version (replacing the
`APPLICATION_VERSION` in the Makefile, as well as the `package.json`
version inside the `.asar`), and the publish scripts get configured to
deploy to different "snapshot" locations.

This commit also reduces the size of the version tag in the bottom right
corner a bit so that it fits when the commit hash is appended to it.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-10 21:37:54 -04:00
Juan Cruz Viotti
0b0b097620 refactor(GUI): extract and test child writer CLI argument utilities (#1012)
These utilities were extracted to `lib/shared/child-writer/cli.js`, and
unit tests have been written for them.

As a result of testing, `.getBooleanArgumentForm()` has been extended to
support single letter options.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-10 21:36:33 -04:00
Juan Cruz Viotti
7fa2f437c1 feat(CLI): replace --robot with an ETCHER_CLI_ROBOT env var (#1010)
The `--robot` option of the CLI causes the program to output
machine-parseable strings, which can be easily consumed by the GUI to
update progress and other information.

The problem is that if the CLI fails to parse its command line arguments
when being called from the GUI for whatever reason, the `.fail()` Yargs
handler will be called, which doesn't output error information in the
usual "robot" format, causing the GUI to not understand the error
message.

Since the `.fail()` Yargs handler doesn't have access to the passed
options, we moved the "robot" functionality to an environment variable,
which we can easily check from there.

As a bonus, this PR refactors the whole robot logic into
`lib/shared/robot.js` and adds unit tests to it.

See: https://github.com/resin-io/etcher/issues/986
Change-Type: major
Changelog-Entry: Replace the `--robot` CLI option with an `ETCHER_CLI_ROBOT` environment variable.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-10 19:46:59 -04:00
Alexis Svinartchouk
b6333067f9 fix(GUI): make the image selection window a modal (#932) (#1009)
The image selection dialog is attached to the parent window so it is a modal.

Change-Type: patch
Changelog-Entry: Make the image file picker attach to the main window.
2017-01-10 17:39:34 -04:00
Juan Cruz Viotti
54b93a56d2 fix(GUI): fix path to Glyphicons Bootstrap font (#1011)
We've recently moved the compiled CSS output to `lib/gui/css/main.css`,
however we didn't update the relative path to Bootstrap icon web font,
causing every icon to break.

See: https://github.com/resin-io/etcher/pull/1002
Change-Type: patch
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-10 17:36:13 -04:00
Juan Cruz Viotti
735478bf52 fix(GUI): don't split robot input by new lines inside properties (#1008)
We've recently PRed a commit that handles multiple IPC messages being
triggered at the same time, confusing `JSON.parse()`. As a solution to
such problem, we are splitting the CLI output on new lines, based on the
assumption that each line represents a different object, however we
didn't consider that in the case of errors, we include an `stacktrace`
property which usually includes new line characters, causing such
information to be completely garbled and cause `JSON.parse()` once again
to get confused.

As a solution, we only split by new lines that are not surrounded by
quotes (since they represent a JSON property).

See: https://github.com/resin-io/etcher/pull/997
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-10 12:25:16 -04:00
Juan Cruz Viotti
404eeffbeb chore: compile CSS into lib/gui/css (#1002)
We currently compile CSS into `build/css`, however we plan to use
node-gyp in this project, which can't be configured to build to a
directory other than `build`, therefore, the compiled CSS must move
somewhere else.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-06 15:55:07 -04:00
Ștefan Daniel Mihăilă
050d187e6f refactor: extract SelectionStateModel stateless functions (#982)
`SelectionStateModel`'s methods `isSystemDrive` and `isDriveLocked`
don't depend on application state. They have been extracted in a different
AngularJS service: `DriveConstraintsModel`. The new service's actual
implementation is in `lib/src`, in order to be reused by the CLI.

Miscellaneous changes:

- Rename `lib/src` to `lib/shared`
- Refactor `drive-constraints` to throw when image is undefined

The default behaviour was to pretend that we're all good if the if
the image is not specified. We're not using this "feature", and
it can be dangerous if we forget to pass in the image.

- Make `isSystemDrive` return `false` if `system` property is undefined
- Use `drive-constraints` in `store.js`

Change-Type: patch
2017-01-06 12:42:11 -04:00
Juan Cruz Viotti
e641265f4d upgrade: etcher-image-write to v9.0.0 (#1000)
This version includes support for retrying up to ten times when EIO
errors are encountered during reading.

See: https://github.com/resin-io-modules/etcher-image-write/pull/70
Fixes: https://github.com/resin-io/etcher/issues/981
Change-Type: patch
Changelog-Entry: Fix sporadic "EIO: i/o error, read" errors during validation.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-06 11:31:16 -04:00
Juan Cruz Viotti
405b98d5ef 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 <jviotti@openmailbox.org>
2017-01-05 13:59:56 -04:00
Benedict Aas
ec3c74d7e5 feat(gui): sort file picker extensions alphabetically (#991)
We sort the supported file extensions listed in the file picker
in alphabetical order.

See: https://github.com/resin-io/etcher/issues/984
Changelog-Entry: Sort supported extensions alphabetically in the image file-picker.
Change-Type: patch
2016-12-30 00:44:13 -04:00
Benedict Aas
de6ad80038 feat(gui): add referers to etcher.io links (#990)
We add referers to the two etcher.io links in the interface—one for the
update link, and one for the footer logo link.

Closes: https://github.com/resin-io/etcher/issues/987
2016-12-30 00:43:31 -04:00
Benedict Aas
d7e1fe09fc feat(gui): label system drives in drive-list widget (#978)
System drives in the drive-list widget now have a red warning label
beneath. Also new is the `isSystemDrive()` method under
`SelectionStateModel` and its unit-tests.

See: https://github.com/resin-io/etcher/issues/888
Changelog-Entry: Label system drives in the drive-list widget
2016-12-16 10:41:04 -04:00
Benedict Aas
cce9ce25d7 feat(gui): show available version in update notifier modal (#928)
We show the Etcher version string in the update notifier modal, by giving
the version string to the template through options similar to the warning
modal.

- We memoize the version Promise and assume the update version won't change
  during runtime.

Changelog-Entry: Show available Etcher version in the update notifier.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-12-06 11:33:52 -04:00
Benedict Aas
e24c2b6466 feat(GUI): confirm before quitting etcher while writing (#868)
When Etcher is writing to a drive and the user closes the window,
currently there is no confirmation. This commit changes that and
the user has to confirm the exit.

Other changes include the warning modal taking a `rejectionLabel` option
that shows a reject button when provided.

Closes: https://github.com/resin-io/etcher/issues/744
Change-Type: minor
Changelog-Entry: Confirm before user quits while writing.
2016-12-05 10:56:38 -04:00
Benedict Aas
ae6b707bb4 feat(gui): add changelog link to update notifier (#920)
We add a blue clickable link to the Github changelog in the update dialog
modal.

Closes: https://github.com/resin-io/etcher/issues/905
Change-Type: patch
Changelog-Entry: Add a changelog link to the update notifier modal.
2016-12-05 10:55:33 -04:00
Benedict Aas
cfeb35b531 feat(GUI): allow double-click to quick-select drives (#889)
The user can now double-click to swiftly select a drive in the
drive widget instead of having to toggle a drive and then clicking the
continue button to close the modal and finalize the drive selection.

Closes: https://github.com/resin-io/etcher/issues/880
Change-Type: patch
Changelog-Entry: Implement double-click to quick-select drives in the
drive widget.
2016-11-30 11:11:11 -04:00
Benedict Aas
ccd2076a20 fix(GUI): show not-allowed cursor over unselectable drives (#886)
The cursor is incorrectly a pointer on hover over a disabled and
unselectable drive in the drive selector widget. This patch changes the
cursor to `not-allowed`, providing the user with visual feedback that it is
not selectable.

Fixes: https://github.com/resin-io/etcher/issues/865
Change-Type: patch
Changelog-Entry: Use not-allowed cursor over disabled drives in the
drive selector widget.
2016-11-30 11:06:41 -04:00
Juan Cruz Viotti
7d51dea35d fix(CLI): always omit first two elements of process.argv (#891)
This is a great simplification to the logic previously included in the
Yargs `.parse()` function on the Etcher CLI.

There is no scenario where the CLI script will be executed in a
standalone fashion (e.g: `etcher.js <options>`), so we can always safely
drop the first two elements from `process.argv`.

Change-Type: patch
Changelog-Entry: Fix command line arguments not interpreted correctly when running the CLI with a custom named NodeJS binary.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-11-25 12:56:54 -04:00
Benedict Aas
18799d4274 fix(GUI): wrap long words in drivelist (#882)
Drives with long names or descriptions expand outside the drivelist,
this commit fixes that using CSS `word-break: break-all`.

Change-Type: patch
Changelog-Entry: Wrap drive names and descriptions in the drive selector widget.
2016-11-18 17:28:10 +00:00
Juan Cruz Viotti
ca4d05ced0 refactor(GUI): resolve undefined on modal keyboard bindings (#879)
Currently we resolve `false`, which might not mean very much to some
modal use cases. `undefined` is a much more generic falsy value.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-11-18 15:23:10 +00:00
Benedict Aas
e85906d50d fix(GUI): pressing escape cancels modal dialogue (#878)
Pressing the ESC key in any modal dialogue currently just emits a
message. This change actually cancels the modal, closing it.

Closes: https://github.com/resin-io/etcher/issues/874
Change-Type: patch
Changelog-Entry: Allow the user to press ESC to cancel a modal dialog.
2016-11-18 12:55:30 +00:00
Juan Cruz Viotti
938fa71d50 fix(GUI): terminate IPC server on any errors (#872)
If the child process (e.g: writer proxy, or CLI) emits either an error,
or an invalid output, the error will be emitted to the GUI, which will
report it to the state machine, however the IPC server will keep
receiving further messages, which will be passed to the GUI, which will
keep trying to update the state, in which case Redux will rightfully
complain that we can't update the flashing state if there is no flash in
process.

As a solution, we make sure the IPC server is terminated on every
possible error code flow, and to do this effectively, we needed to
manually destroy every connected socket before actually closing the
server.

Change-Type: patch
Changelog-Entry: Fix "Can't set the flashing state when not flashing" error.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-11-18 11:58:00 +00:00
Juan Cruz Viotti
9b6cd5c81c chore: update "join us" email to join+etcher@resin.io (#873)
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-11-17 09:05:37 +00:00
Juan Cruz Viotti
6456a8fe96 upgrade: drivelist to v5.0.1 (#869)
- Fix internal SDCard reader descriptions in GNU/Linux.
- Transform `mountpoint` into an array of mountpoints.

Change-Type: patch
Changelog-Entry: Fix internal SDCard drive descriptions.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-11-16 13:52:20 +00:00
Juan Cruz Viotti
8992db807d fix(GUI): kill CLI processes when child writer dies (#855)
Turns out that when the parent process gets SIGKILL, the children
process would still remain alive.

In order to mitigate this, we force the IPC client opened by the child
writer to not attempt to reconnect to the IPC server if this one dies,
so we can catch the "disconnect" event and kill the children as a
result.

Fixes: https://github.com/resin-io/etcher/issues/850
Change-Type: patch
Changelog-Entry: Fix writing process remaining alive after the GUI is closed.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-11-16 00:48:29 +00:00
Juan Cruz Viotti
b4f1d82a51 fix(CLI): check CLI elevation early on (#864)
The CLI requires elevation permissions to actually be able to write to
drives. For this reason, it makes sense that we introduce such a check
early on.

See: https://github.com/resin-io/etcher/issues/726
Change-Type: patch
Changelog-Entry: Check available permissions in the CLI early on.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-11-14 11:22:08 +02:00
Juan Cruz Viotti
4e3bdb7e22 refactor(CLI): move UNIX umount functionality to repository (#866)
- Move UNIX unmount functionality to the CLI module
- Run `electron-mocha` for the CLI code
- Make unmount command templates that take a `drivelist` object as input

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-11-14 11:11:49 +02:00
Benedict Aas
2c07bce25f style(GUI): clarify wording at finished flash prompt (new → different) (#867)
Currently, the wording "same" versus "new" on the completion screen
is ambiguous when they respectively mean use the same image file, or use a new
and different image file. Therefore, change the wording from "new" to
"different".

Closes: https://github.com/resin-io/etcher/issues/839
2016-11-12 11:22:03 +02:00
Juan Cruz Viotti
5a48395d6d style(GUI): unify "close" top right corner X in all modals (#841)
Every modal in the application should contain the same "close" X at the
top right corner, for consistency purposes. The only modal lacking this
button was the update notifier modal.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-11-07 17:56:03 +02:00
Juan Cruz Viotti
5d42fd181a minifix(GUI): improve unsafe mode setting dialog (#840)
- Change dialog message to "Are you sure you want to turn this on? You
  will be able to overwrite your system drives if you're not careful."

- Remove "CANCEL" button and put a cross at the top right corner.

- Change dialog button label from "YES, CONTINUE" to "ENABLE UNSAFE
  MODE"

In order to adapt to changes described above:

- `WarningModalService.display()` now takes an object including
  `description`, and `confirmationLabel`

Fixes: https://github.com/resin-io/etcher/issues/729
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-11-07 17:13:26 +02:00
Juan Cruz Viotti
1cc2cb9bad minifix(GUI): warning modal size class (#838)
The `settings-dangerous-modal` modal size class doesn't exist anymore,
and was renamed to `warning-modal`. This was causing the exclamation
sign from the header to not be displayed in red, as it should.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-11-07 14:25:37 +02:00
Juan Cruz Viotti
5ac486d941 style: refer to Resin.io as resin.io, according to the style manual (#823)
> For all, lower-case capitalization unless beginning a sentence (Ex. I
> like resin.io. Resin.io is great.)

See: https://github.com/resin-io/docs#style-manual
See: https://github.com/resin-io/etcher/issues/797
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-11-03 10:57:29 -04:00
Juan Cruz Viotti
f16e176b0f minifix(GUI): keep settings checkboxes unchecked until user confirms (#821)
There are some settings, such as "unsafe mode", that prompt the user for
confirmation before actually confirming the setting. In these cases,
when the user attempts to check the checkbox, the checkbox remains
checked unless the user rejects the confirmation dialog, in which case
the checkbox value is reverted.

In order to provide a better UX, we now keep the checkbox unchecked
until the user confirms.

See: https://github.com/resin-io/etcher/issues/729
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-11-02 18:25:29 -04:00
Juan Cruz Viotti
e2652e6ee9 style(GUI): improve wording of supported extensions label (#807)
- Change "and many more" to "and others"

See: https://github.com/resin-io/etcher/issues/787
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-11-02 18:24:01 -04:00
Juan Cruz Viotti
9ed6e30b00 style(GUI): improve ordering of supported extensions (#806)
The new ordering of the main supported extensions will be: `img`, `iso`,
`zip`.

We make use of `_.intersection` in order to ensure that the values we're
hardcoding indeed exist in the list of all supported format extensions,
otherwise they won't appear at all. This ensures we never show
extensions that are not supported.

Partly fixes: https://github.com/resin-io/etcher/issues/787
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-11-02 14:28:21 -04:00
Juan Cruz Viotti
0c66fb65f4 fix(GUI): close IPC server after writing (#816)
Currently, we are not making sure the IPC server we start at
`lib/src/child-writer/index.js` gets closed when the child process exits
(successfully or not). This eventually causes issues when the user click
"flash again", since the stateful `ipc` global exposed by `node-ipc`
gets initialised again, causing the module to get to an invalid state
that eventually results in `this.log is not a function`.

- We've added `ipc.server.stop()` to both the `error` and `close` event
  handlers (which are self exclusive, according to the docs).

- We've added `child.kill()` to the child `stderr` handler, since that
  function causes the `close` event to be triggered, which in turns
  calls `ipc.server.stop()`.

Change-Type: patch
Changelog-Entry: Fix `this.log is not a function` error when clicking "flash again".
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-11-02 00:00:39 -04:00