This repository was archived by the owner on Jun 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·49 lines (40 loc) · 1.34 KB
/
index.js
File metadata and controls
executable file
·49 lines (40 loc) · 1.34 KB
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
#!/usr/bin/env node
'use strict';
const axios = require('axios');
const spawn = require('cross-spawn');
const yargs = require('yargs');
const chalk = require('chalk');
const latestVersion = require('latest-version');
const pkg = require('./package.json');
// Display update notification if it's not the last version
latestVersion('toolbox-utils')
.then(version => {
if (version !== pkg.version) {
const msg = ` Version ${version} (current ${pkg.version}) of toolbox-utils is available ! `;
console.log(`
${chalk.white.bgRed.bold(` ${' '.repeat(msg.length)} \n ${msg} \n${' '.repeat(msg.length)} `)}
To update your beloved builder, do :
$ ${chalk.green('yarn upgrade toolbox-utils')} (recommended)
or
$ ${chalk.green('npm update toolbox-utils')}
`);
}
})
.catch(err => err);
const script = process.argv[2];
const args = process.argv[3] ? '--' + process.argv[3] : process.argv[3];
let env = script === 'build' ? '--production' : '--dev';
const binaries = ['deploy'];
if (binaries.includes(script)) {
spawn(
'sh',
[`./bin/${script}.sh`, '--project', process.cwd(), env, args],
{ stdio: 'inherit', cwd: './node_modules/toolbox-utils' },
);
} else {
spawn(
'./node_modules/.bin/gulp',
[script, '--project', process.cwd(), env, args],
{ stdio: 'inherit', cwd: './node_modules/toolbox-utils' },
);
}