From 89912d2ba77252fe322098ac3adc05428772e827 Mon Sep 17 00:00:00 2001 From: Sean Doyle Date: Thu, 17 Mar 2016 13:51:33 -0400 Subject: [PATCH] Fail `ember:compile` if build subprocess fails Closes [#417]. The following is the command `ember-cli-rails` generates for `rake ember:compile`. It was generated using [the example application][repo]. ```bash /Users/seanpdoyle/src/ember-cli-rails-heroku-example/frontend/node_modules/.bin/ember build --environment 'development' --output-path '/Users/seanpdoyle/src/ember-cli-rails-heroku-example/tmp/ember-cli/apps/frontend' | /usr/bin/tee -a '/Users/seanpdoyle/src/ember-cli-rails-heroku-example/log/ember-frontend.development.log' Pipes are streaming, so the pipe to `tee` will open before the first program finishes writing, potentially ignoring a non-zero exit status. The solution is to set the [`pipefail`][docs] option for the generated sub-command. [repo]: https://github.com/seanpdoyle/ember-cli-rails-heroku-example [#417]: https://github.com/thoughtbot/ember-cli-rails/issues/417 [docs]: http://www.gnu.org/software/bash/manual/html_node/Pipelines.html --- lib/ember_cli/command.rb | 2 +- spec/lib/ember_cli/command_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/ember_cli/command.rb b/lib/ember_cli/command.rb index 054c4d3e..60ea02b7 100644 --- a/lib/ember_cli/command.rb +++ b/lib/ember_cli/command.rb @@ -14,7 +14,7 @@ def test end def build(watch: false) - "#{ember_build(watch: watch)} | #{tee}" + "set -o pipefail; #{ember_build(watch: watch)} | #{tee}" end private diff --git a/spec/lib/ember_cli/command_spec.rb b/spec/lib/ember_cli/command_spec.rb index 4b93812f..26cbcb09 100644 --- a/spec/lib/ember_cli/command_spec.rb +++ b/spec/lib/ember_cli/command_spec.rb @@ -25,6 +25,13 @@ expect(command.build).to match(%r{\| path/to/tee -a 'path/to/log'}) end + it "sets pipefail" do + paths = build_paths(tee: "path/to/tee", log: "path/to/log") + command = build_command(paths: paths) + + expect(command.build).to match(%r{\Aset -o pipefail;}) + end + context "when building in production" do it "includes the `--environment production` flag" do paths = build_paths