UNPKG

1.07 kBJavaScriptView Raw
1import fs from 'fs';
2import npath from 'path';
3import url from 'url';
4
5import commander from 'commander';
6
7const { program } = commander;
8const { path: thisPath } = url.parse(import.meta.url);
9const packagePath = `${npath.dirname(thisPath)}/../package.json`;
10const { version } = JSON.parse(fs.readFileSync(packagePath));
11
12export 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);