-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·25 lines (19 loc) · 748 Bytes
/
cli.js
File metadata and controls
executable file
·25 lines (19 loc) · 748 Bytes
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
#!/usr/bin/env node
var program = require('commander');
var path = require('path');
var {version} = require('./package.json');
var app = require('./app.js');
function resolvePath(relativePath) {
console.log(path.join(process.cwd(), relativePath))
return path.join(process.cwd(), relativePath);
}
program
.version(version)
.usage('[options] <spec>')
.option('-m, --mock <dir>', 'path to mock directory', resolvePath)
.option('-c, --config <file>', 'path to config file', resolvePath)
.option('-p, --port <n>', 'port to start the mock server on', parseInt);
program.parse(process.argv);
const spec = program.args[0] ? resolvePath(program.args[0]) : undefined;
const {mock, config, port} = program;
app({spec, mock, config, port})