-
Notifications
You must be signed in to change notification settings - Fork 5
/
tasks.js
45 lines (45 loc) · 2.25 KB
/
tasks.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
37
38
39
40
41
42
43
44
45
// -------------------------------------------------------------------------------
// Clean
// -------------------------------------------------------------------------------
export async function clean() {
await folder('target').delete().exec()
await folder('dist').delete().exec()
}
// -------------------------------------------------------------------------------
// Format
// -------------------------------------------------------------------------------
export async function format() {
await shell('prettier --no-semi --single-quote --print-width 240 --trailing-comma all --write src website').exec()
}
// -------------------------------------------------------------------------------
// Start
// -------------------------------------------------------------------------------
export async function start(target = 'target/watch') {
const options = 'serve website/index.html --dist target/website --serve 5000'
await file(`${target}/cli.js`).create().exec()
await Promise.all([
shell(`tsc --project src/tsconfig.json --outDir ${target} --watch`).exec(),
shell(`smoke-run ${target} -x node ${target}/cli.js ${options}`).exec(),
])
}
// -------------------------------------------------------------------------------
// Build
// -------------------------------------------------------------------------------
export async function build(target = 'target/build') {
await folder(`${target}`).delete().exec()
await file(`${target}/index.js`).create().exec()
await shell(`tsc --project src/tsconfig.json --outDir ${target} --declaration`).exec()
await folder(`${target}`).add('src/hammer').exec()
await folder(`${target}`).add('package.json').exec()
await folder(`${target}`).add('license').exec()
await folder(`${target}`).add('readme.md').exec()
await shell(`cd ${target} && npm pack`).exec()
}
// -------------------------------------------------------------------------------
// Install (may require administrator)
// -------------------------------------------------------------------------------
export async function install_cli(target = 'target/build') {
await build()
const packageJson = JSON.parse(await file('./package.json').read('utf-8'))
await shell(`cd ${target} && npm install sinclair-hammer-${packageJson['version']}.tgz -g`).exec()
}