1 | import fs from 'fs';
|
2 | import npath from 'path';
|
3 | import url from 'url';
|
4 |
|
5 | import commander from 'commander';
|
6 |
|
7 | const { program } = commander;
|
8 | const { path: thisPath } = url.parse(import.meta.url);
|
9 | const packagePath = `${npath.dirname(thisPath)}/../package.json`;
|
10 | const { version } = JSON.parse(fs.readFileSync(packagePath));
|
11 |
|
12 | export default argv =>
|
13 | program
|
14 | .version(version)
|
15 | .description('The fast file transform pipeline.')
|
16 | .option('-c, --config-path [path]', 'load config from [path]', 'cogs.js')
|
17 | .option(
|
18 | '-d, --debounce [seconds]',
|
19 | 'trigger a build at most every [seconds] seconds',
|
20 | parseFloat,
|
21 | 0.1
|
22 | )
|
23 | .option(
|
24 | '-w, --watch-paths [path]',
|
25 | 'rebuild if [path] changes, can be specified multiple times',
|
26 | (path, paths = []) => [].concat(paths, path)
|
27 | )
|
28 | .option(
|
29 | '-p, --use-polling',
|
30 | 'use stat polling instead of fsevents when watching'
|
31 | )
|
32 | .option('-s, --silent', 'do not output build information, only errors')
|
33 | .option('-C, --no-color', 'disable colored output')
|
34 | .parse(argv);
|