-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·52 lines (44 loc) · 1.22 KB
/
index.js
File metadata and controls
executable file
·52 lines (44 loc) · 1.22 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
50
51
52
#!/usr/bin/env node
/*
* @Author: insane.luojie
* @Date: 2017-09-02 00:37:06
* @Last Modified by: insane.luojie
* @Last Modified time: 2017-09-27 10:40:43
*/
'use strict';
const pkg = require("../package");
const path = require('path');
const spawn = require('cross-spawn');
const script = process.argv[2];
const args = process.argv.slice(3);
const existsSync = require("fs").existsSync;
const printAndExit = require("./utils");
const {resolve, join} = path;
process.on('unhandledRejection', err => {
throw err;
});
const dir = resolve('.');
console.log("> blade version: ", pkg.version);
console.log(' ');
// 检查目录
if (!existsSync(join(dir, 'pages'))) {
printAndExit('> Couldn\'t find a `pages` directory. Please create one under the project root' )
}
switch (script) {
case 'build':
case 'source':
case 'dev':
{
const result = spawn.sync(
'node', [require.resolve('./tasks/' + script)].concat(args), { stdio: 'inherit' }
);
if (result.signal) {
process.exit(1);
}
process.exit(result.status);
break;
}
default:
console.log('Unknown script "' + script + '".');
break;
}