-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
executable file
·53 lines (44 loc) · 1.25 KB
/
index.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
#!/usr/bin/env node
import { program } from 'commander';
import fs from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import diff from './tasks/diff.js';
import snapshot from './tasks/snapshot.js';
const dirname = path.dirname(fileURLToPath(import.meta.url));
const packageJson = JSON.parse(await fs.readFile(path.join(dirname, 'package.json')));
// Take snapshot
program.command('snapshot')
.option(
'-c, --config <path>',
'use this configuration, overriding default config options if present',
)
.option(
'-o, --output <path>',
`output filepath (default: ".${path.sep}harold_snapshot_<date>_<time>.json")`,
)
.option(
'-e, --exec <cmd>',
'build command (default: "npm run build-production")',
)
.option(
'-p, --path <path>',
'build path (default: "public")',
)
.description('build project and take snapshot')
.action(snapshot);
// Compare snapshots
program.command('diff <left> <right>')
.description('compare snapshots')
.action(diff);
program
.usage('[options]')
.version(packageJson.version, '-V, --version')
.description(packageJson.description)
.parse(process.argv);
if (program.args.length === 0) {
program.help();
}
process.on('unhandledRejection', error => {
console.error(error);
});