-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.js
56 lines (47 loc) · 1.5 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
46
47
48
49
50
51
52
53
54
55
56
const { folder, shell } = require('./tools')
/** Cleans this project. */
async function clean() {
await folder('node_modules').delete().exec().catch(() => { /** cannot delete @types on windows */})
await folder('public').delete().exec()
}
/** Builds this project. */
async function build() {
await shell('tsc --project src/tsconfig.json --outDir public/bin --removeComments').exec()
await shell('tsc --project src/tsconfig.json --outDir public/bin --declaration --emitDeclarationOnly').exec()
await folder('public/bin').add('package.json').exec()
}
/** Builds the tools for this project. */
async function tools() {
await shell('tsc-bundle ./src/tsconfig.json --outFile ./tools/index.js --exportAs commonjs').exec()
await folder('tools').remove('index.js.map').exec()
}
/** Runs tests for this project. */
async function test() {
await shell('tsc-bundle test/tsconfig.json --outFile public/test/index.js').exec()
await shell('mocha public/test/index.js').expect(0).exec().catch(() => process.exit(1))
}
/** Packs this project for NPM deployment. */
async function pack() {
await build()
await folder('public/pack')
.delete()
.create()
.merge_from('public/bin')
.add('package.json')
.add('readme.md')
.add('license')
.exec()
await shell('cd public/pack && npm pack').exec()
}
/** Command Line interface. */
async function cli (args, tasks) {
const [_, __, task] = args
await tasks[task]()
}
cli(process.argv, {
clean,
build,
tools,
test,
pack
}).catch(console.log)