-
Notifications
You must be signed in to change notification settings - Fork 16
/
smoke-conv-cli.js
46 lines (35 loc) · 1.21 KB
/
smoke-conv-cli.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
const minimist = require('minimist');
const {convert} = require('./lib/convert');
const help = `Usage: smoke-conv <input_mocks_or_collection> <output_file_or_folder>
Convert a single file mock collection to separate mock files and conversely.
If the input is a single file mock collection (.mocks.js), it will be converted
to separate mock files in <output_folder>.
If the input is a set of separate mock files, it will be converted to a single
file mock collection named <output_file>.mocks.js
Options:
-i, --ignore <glob> Files to ignore [default: none]
-d, --depth <N> Folder depth for mocks [default: 1]
-v, --version Show version
--help Show help
`;
async function run(args) {
const options = minimist(args, {
number: ['depth'],
string: ['ignore'],
boolean: ['help', 'version'],
alias: {
v: 'version',
i: 'ignore',
d: 'depth'
}
});
if (options.version) {
const pkg = require('./package.json');
return console.log(pkg.version);
}
if (options.help || options._.length !== 2) {
return console.log(help);
}
await convert(options._[0], options._[1], options.ignore, options.depth);
}
module.exports = run;