From 8723f219491e5b6989cdf6bdbfffb35a4c37ef79 Mon Sep 17 00:00:00 2001 From: Palash Mondal Date: Sun, 5 May 2019 11:30:36 +0530 Subject: [PATCH] fix(build): exit script with error --- src/build.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/build.js b/src/build.js index b9e32b1a..f9157130 100644 --- a/src/build.js +++ b/src/build.js @@ -5,8 +5,9 @@ const token = require('./token') const debug = require('./debug') let pass = () => {} // noop -let fail = () => process.exit(1) -let error = () => process.exit(1) +const exit = () => process.exit(1) +let fail = exit +let error = exit const label = 'bundlesize' const description = 'Checking output size...' @@ -28,8 +29,16 @@ if (token) { build.start().catch(handleError) pass = (message, url) => build.pass(message, url).catch(handleError) - fail = (message, url) => build.fail(message, url).catch(handleError) - error = (message, url) => build.error(message, url).catch(handleError) + fail = (message, url) => + build + .fail(message, url) + .catch(handleError) + .then(exit) + error = (message, url) => + build + .error(message, url) + .catch(handleError) + .then(exit) } module.exports = { pass, fail, error }