Skip to content

Commit

Permalink
Exit script with error (#9)
Browse files Browse the repository at this point in the history
Exit script with error
  • Loading branch information
palashmon authored May 5, 2019
2 parents c7f6c94 + 8723f21 commit 8b8fd09
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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...'
Expand All @@ -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 }

0 comments on commit 8b8fd09

Please sign in to comment.