From 351003b4fe4764287f2c21d23021988533d327fe Mon Sep 17 00:00:00 2001 From: Adam Heath Date: Thu, 18 Feb 2016 12:41:48 +0800 Subject: [PATCH] Make build fail when external_pipeline fails --- middleman-core/features/builder.feature | 12 ++++++++---- .../fixtures/external-pipeline-error/config.rb | 5 +++++ .../source/javascripts/file.js | 0 .../middleman-core/extensions/external_pipeline.rb | 5 +++++ 4 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 middleman-core/fixtures/external-pipeline-error/config.rb create mode 100644 middleman-core/fixtures/external-pipeline-error/source/javascripts/file.js diff --git a/middleman-core/features/builder.feature b/middleman-core/features/builder.feature index b61f5cdc..d99c165c 100644 --- a/middleman-core/features/builder.feature +++ b/middleman-core/features/builder.feature @@ -20,13 +20,13 @@ Feature: Builder | layout | | layouts/custom | | layouts/content_for | - + And the file "index.html" should contain "Comment in layout" And the file "index.html" should contain "

Welcome

" And the file "static.html" should contain "Static, no code!" And the file "services/index.html" should contain "Services" And the file "stylesheets/static.css" should contain "body" - + Scenario: Build glob Given a successfully built app at "glob-app" with flags "--glob '*.css'" When I cd to "build" @@ -34,15 +34,19 @@ Feature: Builder | index.html | Then the following files should exist: | stylesheets/site.css | - + Scenario: Build with errors Given a built app at "build-with-errors-app" Then the exit status should be 1 - + Scenario: Build empty errors Given a built app at "empty-app" Then the exit status should be 1 + Scenario: Build external_pipeline errors + Given a built app at "external-pipeline-error" + Then the exit status should be 1 + Scenario: Build alias (b) Given a fixture app "large-build-app" When I run `middleman b` diff --git a/middleman-core/fixtures/external-pipeline-error/config.rb b/middleman-core/fixtures/external-pipeline-error/config.rb new file mode 100644 index 00000000..96bb2b94 --- /dev/null +++ b/middleman-core/fixtures/external-pipeline-error/config.rb @@ -0,0 +1,5 @@ +activate :external_pipeline, + name: :failing, + command: "mv does-not-exist tmp/file.js", + source: "tmp", + latency: 2 diff --git a/middleman-core/fixtures/external-pipeline-error/source/javascripts/file.js b/middleman-core/fixtures/external-pipeline-error/source/javascripts/file.js new file mode 100644 index 00000000..e69de29b diff --git a/middleman-core/lib/middleman-core/extensions/external_pipeline.rb b/middleman-core/lib/middleman-core/extensions/external_pipeline.rb index 6b51d944..0e09dc17 100644 --- a/middleman-core/lib/middleman-core/extensions/external_pipeline.rb +++ b/middleman-core/lib/middleman-core/extensions/external_pipeline.rb @@ -34,6 +34,11 @@ class Middleman::Extensions::ExternalPipeline < ::Middleman::Extension end end + unless $?.success? + logger.error '== External: Command failed with non-zero exit status' + exit(1) + end + @watcher.poll_once! rescue ::Errno::ENOENT => e logger.error "== External: Command failed with message: #{e.message}"