guido
Version:
基于webpack4的一键式开发工具,集成handlebars、雪碧图、SVG Sprite、自定义资源注入等方式
38 lines (33 loc) • 923 B
JavaScript
;
process.on('unhandledRejection', err => {
throw err;
});
const path = require('path');
const spawn = require('cross-spawn');
const chalk = require('chalk');
const script = process.argv.slice(2)[0];
if (script === 'build' || script === 'start' || script === 'test') {
const result = spawn.sync(
'node',
[require.resolve(path.join(__dirname, '../lib/scripts/' + script))],
{ stdio: 'inherit' }
);
if (result.signal) {
if (result.signal === 'SIGKILL') {
console.log(
chalk.red('内存不足或调用了 `kill -9`,导致进程已退出。')
);
} else if (result.signal === 'SIGTERM') {
console.log(
chalk.red(
'调用了 `kill` or `killall` 或 系统正进行关闭,导致进程已退出。'
)
);
}
process.exit(1);
}
process.exit(result.status);
} else {
console.log(chalk.yellow('"' + script + '"? 这是未知的处理命令'));
}