forked from garris/BackstopJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·54 lines (45 loc) · 1.17 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
54
#!/usr/bin/env node
var parseArgs = require('minimist');
var usage = require('./usage');
var version = require('../package.json').version;
var runner = require('../core/runner');
var argsOptions = parseArgs(process.argv.slice(2), {
boolean: ['h', 'help', 'v', 'version', 'i'],
string: ['config'],
default: {
config: 'backstop.json'
}
});
// Catch errors from failing promises
process.on('unhandledRejection', function (error) {
console.error(error && error.stack);
});
if (argsOptions.h || argsOptions.help) {
console.log(usage);
process.exit();
}
if (argsOptions.v || argsOptions.version) {
console.log('BackstopJS v' + version);
process.exit();
}
var commandName = argsOptions['_'][0];
if (!commandName) {
console.log(usage);
process.exit();
} else {
var exitCode = 0;
console.log('BackstopJS v' + version);
runner(commandName, argsOptions).catch(function () {
exitCode = 1;
});
/*
* Wait for the stdout buffer to drain.
*/
process.on('exit', function (code) {
process.exit(code || exitCode);
});
process.on('uncaughtException', function (err) {
console.log('Uncaught exception:', err.message, err.stack);
throw err;
});
}