-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
36 lines (28 loc) · 811 Bytes
/
cli.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
36
#!/usr/bin/env node
import isCI from 'is-ci'
import { log } from './utility/log.js'
import * as scripts from './script/index.js'
import { getOptions } from './utility/options.js'
import { writeConfiguration } from './utility/configuration.js'
let script = process.argv.slice(2)[0]
if (['watch', 'build', 'test', 'cypress', 'lint', 'release', 'update'].includes(script)) {
const watch = script === 'watch'
if (watch) {
script = 'build'
}
await writeConfiguration()
const options = getOptions()
try {
scripts[script](options, watch)
} catch (error) {
log(`script ${script} exited with an error`)
if (script !== 'test' && !isCI) {
console.log(error)
}
if (isCI) {
throw new Error(error)
}
}
} else {
log('Please provide a valid script', 'error')
}