-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
main.ts
69 lines (60 loc) · 1.91 KB
/
main.ts
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
57
58
59
60
61
62
63
64
65
66
67
68
69
import yargs from "yargs"
import cp from "child_process"
import chalk from "chalk"
const {magenta} = chalk
export const argv = yargs.help(false).options({
// paths
"build-dir": {type: "string"},
// lint
fix: {type: "boolean", default: false},
// scripts, compiler
cache: {type: "boolean", default: true},
// scripts, compiler, test
rebuild: {type: "boolean", default: false},
// scripts
detectCycles: {type: "boolean", default: true},
// server, test
host: {type: "string", default: "127.0.0.1"},
// server
port: {type: "number", default: 5877},
inspect: {type: "boolean", default: false},
// test
executable: {type: "string", alias: "e"},
debug: {type: "boolean", default: false},
keyword: {type: "string", array: true, alias: "k"},
grep: {type: "string", array: true},
ref: {type: "string"},
"baselines-root": {type: "string"},
randomize: {type: "boolean"},
seed: {type: "number"},
pedantic: {type: "boolean"},
screenshot: {type: "string", choices: ["test", "save", "skip"] as const, default: "test"},
}).parseSync()
import {task, run, log, task_names, show_error, show_failure} from "./task"
import "./tasks"
const node_version = process.version
function npm_version(): string {
return cp.execSync("npm --version").toString().trim()
}
async function main(): Promise<void> {
log(`Using nodejs ${magenta(node_version)} and npm ${magenta(npm_version())}`)
const {_} = argv
if (_.length != 0 && _[0] == "help") {
log(`tasks: ${task_names().filter((name) => !name.includes(":")).join(", ")}`)
} else {
const tasks = _.length != 0 ? _.map((arg) => `${arg}`) : ["default"]
const top_level = task("top-level", tasks)
try {
const result = await run(top_level)
if (result.is_Failure()) {
show_failure(result)
process.exit(1)
}
} catch (error) {
show_error(error)
process.exit(1)
}
}
process.exit(0)
}
void main()