-
Notifications
You must be signed in to change notification settings - Fork 0
/
_z.js
executable file
·33 lines (30 loc) · 920 Bytes
/
_z.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
#!/usr/bin/env node
import { registerGlobals, createInterpreter } from './lib/interpreter.js';
import { $, ProcessOutput } from 'zx';
import * as optionsParser from './lib/parse-options.js';
await (async function main() {
registerGlobals();
$.verbose = argv.verbose;
_z.program.configureOutput({
writeOut: str => {
console.log(chalk.green(str));
},
writeErr: str => {
console.error(chalk.red(`${str}`));
},
});
try {
const scriptName = argv._[0];
const defaultOptions = optionsParser.parseAndEvaluateOptions('./cli/commands/index.js');
const interpreter = createInterpreter(scriptName, process.argv.slice(1), defaultOptions);
interpreter.preprocess();
await interpreter.execute();
} catch (p) {
if (p instanceof ProcessOutput) {
console.error(fmtErrStr(p.message));
return (process.exitCode = 1);
} else {
throw p;
}
}
})();