madsflensted / elm-brunch

Brunch plugin to compile Elm code
MIT License
74 stars 31 forks source link

Don't crash Brunch process when Elm compilation fails #33

Closed antonyshchenko closed 7 years ago

antonyshchenko commented 7 years ago

Currently brunch watch process crashes whenever there is a compilation error in Elm code. This is an attempt to fix the issue which works for me currently.

dustinfarris commented 7 years ago

i have not experienced any crashes during brunch watch. i wonder if this is specific to your setup?

antonyshchenko commented 7 years ago

@dustinfarris I was running it inside Docker container. Here is a repo where crash is reproducible: https://github.com/env0der/elmbrunch_crash

Everything works perfectly when I run it on Mac OS, though.

madsflensted commented 7 years ago

@env0der are you sure it is a compilation error? The childExecution will fail only if something is terribly wrong (e.g. can't find compiler or similar).

What kind of error are you getting from the call of the compiler?

antonyshchenko commented 7 years ago

@madsflensted it's documented in the repo https://github.com/env0der/elmbrunch_crash:

20:05:34 - error: Command failed: elm-make --yes --output ../../priv/static/js/elm/main.js Main.elm
-- NAMING ERROR ------------------------------------------------------- Main.elm

Cannot find type `Htm`

6| main : Htm a
          ^^^
Maybe you want one of the following?

    Html
    Html.Html

Stack trace was suppressed. Run with `LOGGY_STACKS=1` to see the trace.
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: spawn notify-send ENOENT
  at exports._errnoException (util.js:1022:11)
  at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
  at onErrorNT (internal/child_process.js:359:16)
  at _combinedTickCallback (internal/process/next_tick.js:74:11)
  at process._tickCallback (internal/process/next_tick.js:98:9)
madsflensted commented 7 years ago

Finally had time to look at this. I had missed that execSync throws exception on any non-zero exit codes from the child process. May need to add some output handling as well.

Thank you for contributing.