|
1 | 1 | #!/usr/bin/env node |
2 | 2 |
|
3 | 3 | 'use strict'; |
4 | | -var chalk = require('chalk'), |
5 | | - gulp = require('gulp'), |
6 | | - pkg = require('../package.json'), |
7 | | - utils = require('../lib/utils'), |
8 | | - veeva = require('../index'); |
| 4 | +const chalk = require('chalk'), |
| 5 | + gulp = require('gulp'), |
| 6 | + pkg = require('../package.json'), |
| 7 | + utils = require('../lib/utils'), |
| 8 | + veeva = require('../index'); |
9 | 9 |
|
10 | | -var nodeVersion = utils.getVersion(process.version.replace('v', '').split('.')), |
11 | | - requiredNodeVersion = utils.getVersion(pkg.engines.node.replace('>=', '').split('.')); |
| 10 | +const nodeVersion = utils.getVersion(process.version.replace('v', '').split('.')), |
| 11 | + requiredNodeVersion = utils.getVersion(pkg.engines.node.replace('>=', '').split('.')); |
12 | 12 |
|
13 | 13 |
|
14 | 14 | // check node version compatibility |
15 | 15 | if (nodeVersion.major < requiredNodeVersion.major) { |
16 | | - console.log(); |
17 | | - console.error(utils.log.chalk.red.bold('✗ '), utils.log.chalk.red.bold('NODE ' + process.version + ' was detected. Veeva requires node version ' + pkg.engines.node)); |
18 | | - console.log(); |
19 | | - process.exit(1); |
| 16 | + console.log(); |
| 17 | + console.error(utils.log.chalk.red.bold('✗ '), utils.log.chalk.red.bold('NODE ' + process.version + ' was detected. Veeva requires node version ' + pkg.engines.node)); |
| 18 | + console.log(); |
| 19 | + process.exit(1); |
20 | 20 | } |
21 | 21 |
|
22 | | -var args = [].slice.call(process.argv, 2); |
| 22 | +const args = [].slice.call(process.argv, 2); |
23 | 23 |
|
24 | | -function checkForCommand(command) { |
| 24 | +function checkForCommand (command) { |
25 | 25 |
|
26 | | - var commands = [ |
27 | | - 'build', |
28 | | - 'stage', |
29 | | - 'deploy', |
30 | | - 'vault-stage' |
31 | | - ]; |
| 26 | + const commands = [ |
| 27 | + 'build', |
| 28 | + 'deploy', |
| 29 | + 'screenshots', |
| 30 | + 'stage', |
| 31 | + 'vault-stage' |
| 32 | + ]; |
32 | 33 |
|
33 | | - return commands.indexOf(command) > -1; |
| 34 | + return commands.includes(command); |
34 | 35 | } |
35 | 36 |
|
36 | 37 |
|
37 | | -return veeva.cli(args).then((options) => { |
38 | | - |
39 | | - return new Promise(function (resolve, reject) { |
40 | | - |
41 | | - // import gulp tasks |
42 | | - require('../lib/gulp')(gulp, options); |
43 | | - |
44 | | - var gulpCommand = checkForCommand(args[0]) ? args[0] : 'default'; |
45 | | - |
46 | | - console.log(); |
47 | | - console.log(chalk.yellow.bold(' ⤷ Running veeva workflow: '), chalk.underline.yellow(gulpCommand)); |
48 | | - console.log(); |
49 | | - |
50 | | - /** |
51 | | - * @notes: |
52 | | - * * gulp.start will be depreciated in Gulp v4 |
53 | | - * * replace with gulp.series |
54 | | - */ |
55 | | - gulp.start(gulpCommand, function(err) { |
56 | | - if (err) { |
57 | | - reject(err); |
58 | | - } else { |
59 | | - resolve(); |
60 | | - } |
61 | | - }); |
| 38 | +return veeva.cli(args) |
| 39 | + .then((options) => new Promise(function (resolve, reject) { |
| 40 | + |
| 41 | + // import gulp tasks |
| 42 | + require('../lib/gulp')(gulp, options); |
| 43 | + |
| 44 | + const gulpCommand = checkForCommand(args[0]) ? args[0] : 'default'; |
| 45 | + |
| 46 | + console.log(); |
| 47 | + console.log(chalk.yellow.bold(' ⤷ Running veeva workflow: '), chalk.underline.yellow(gulpCommand)); |
| 48 | + console.log(); |
| 49 | + |
| 50 | + /** |
| 51 | + * @notes: |
| 52 | + * * gulp.start will be depreciated in Gulp v4 |
| 53 | + * * replace with gulp.series |
| 54 | + */ |
| 55 | + gulp.start(gulpCommand, function (err) { |
| 56 | + if (err) { |
| 57 | + reject(err); |
| 58 | + } else { |
| 59 | + resolve(); |
| 60 | + } |
| 61 | + }); |
| 62 | + })) |
| 63 | + .catch((err) => { |
| 64 | + console.error(('\n\n', chalk.red.bold('✗ '), err)); |
62 | 65 | }); |
63 | | - |
64 | | -}).catch((err) => { |
65 | | - console.error(('\n\n', chalk.red.bold('✗ '), err)); |
66 | | -}); |
67 | | - |
0 commit comments