-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathindex.js
50 lines (36 loc) · 1.06 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
'use strict';
var chalk = require('chalk'),
pkg = require('./package.json');
var nodeVersion = process.version.replace('v',''),
nodeVersionRequired = pkg.engines.node.replace('>=','');
// check node version compatibility
if(nodeVersion <= nodeVersionRequired){
console.log();
console.error(chalk.red.bold('✗ '), chalk.red.bold('Veeva requires node version ' + pkg.engines.node));
console.log();
process.exit(1);
}
var veeva = require('./lib/veeva'),
args = [].slice.call(process.argv, 2),
exitCode = 0,
isDebug = args.indexOf('--debug') !== -1;
module.exports = function(gulp) {
veeva.cli(args).then(function(options) {
if (options) {
// import gulp tasks
require('./gulp')(gulp, options);
} else {
process.exit(exitCode);
}
}).catch(function(err) {
exitCode = 1;
if (!isDebug) {
console.error(err);
} else {
throw new Error(err);
}
});
};
process.on('exit', function() {
process.exit(exitCode);
});