UNPKG

852 BPlain TextView Raw
1import { execute } from './helpers/shell.helpers';
2import { bailIf, parseFlags } from './helpers/utility.helpers';
3
4interface Options {
5 clean: boolean;
6 lint: boolean;
7 watch: boolean;
8 test: boolean;
9}
10
11const defaultOptionsFn = (args: Options) => ({
12 clean: true,
13 lint: !args.watch,
14 watch: false,
15 test: !args.watch
16});
17
18const options = parseFlags(process.argv.slice(2), defaultOptionsFn);
19
20bailIf(options.watch && options.test, '--watch and --test are mutually exclusive.');
21
22(async () => {
23 if (options.clean) {
24 await execute('rimraf ./dist ./dist-spec');
25 }
26
27 if (options.lint) {
28 await execute('ts-node ./build/lint.ts');
29 }
30
31 await execute(`tsc --project ./tsconfig.json ${options.watch ? '--watch' : ''}`);
32
33 if (options.test) {
34 await execute('ts-node ./build/test.ts');
35 }
36})();