-
-
Notifications
You must be signed in to change notification settings - Fork 180
/
build.js
35 lines (27 loc) · 1009 Bytes
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const Build = require('github-build')
const prettycli = require('prettycli')
const { repo, sha } = require('ci-env')
const token = require('./token')
const debug = require('./debug')
let pass = () => {} // noop
let fail = () => process.exit(1)
let error = () => process.exit(1)
const label = 'bundlesize'
const description = 'Checking output size...'
const meta = { repo, sha, token, label, description }
const build = new Build(meta)
debug('token exists', !!token)
debug('repo', repo)
debug('sha', sha)
if (token) {
const handleError = err => {
const message = `Could not add github status.
${err.status}: ${err.error.message}`
prettycli.error(message, { silent: true, label: 'ERROR' })
}
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)
}
module.exports = { pass, fail, error }