From 473345578f2977d6c4833bb930a4c8fb7fdae436 Mon Sep 17 00:00:00 2001 From: Mathias Biilmann Christensen Date: Tue, 18 Oct 2016 22:40:29 -0700 Subject: [PATCH] Make sure to exit with non-zero exit code on hugo error If hugo fails to build the site, we want to make sure gulp exits with an appropriate error code so a netlify deploy fails --- gulpfile.babel.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gulpfile.babel.js b/gulpfile.babel.js index b3c942c..2b62726 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -53,8 +53,13 @@ gulp.task("server", ["hugo", "css", "js"], () => { function buildSite(cb, options) { const args = options ? defaultArgs.concat(options) : defaultArgs; - return cp.spawn(hugoBin, args, {stdio: "inherit"}).on("close", () => { - browserSync.reload(); - cb(); + return cp.spawn(hugoBin, args, {stdio: "inherit"}).on("close", (code) => { + if (code === 0) { + browserSync.reload(); + cb(); + } else { + browserSync.notify("Hugo build failed :("); + cb("Hugo build failed"); + } }); }