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
This commit is contained in:
Mathias Biilmann Christensen 2016-10-18 22:40:29 -07:00
parent 742a26610c
commit 473345578f
1 changed files with 8 additions and 3 deletions

View File

@ -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");
}
});
}