-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathshell.js
More file actions
35 lines (28 loc) · 680 Bytes
/
shell.js
File metadata and controls
35 lines (28 loc) · 680 Bytes
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
/**
* Created by WindomZ on 17-7-3.
*/
'use strict';
const shell = require('shelljs');
const loader = require('./loader');
function execScripts(scripts) {
if (scripts && scripts.length > 0) {
scripts.every(script => {
if (script && shell.exec(script).code !== 0) {
throw new EvalError('Error: Fail to execute "' + script + '"!');
}
return true;
});
}
}
function execSync(dir) {
return execScripts(loader.loadSync(dir));
}
function* exec(dir) {
return yield execScripts(loader.loadSync(dir));
}
module.exports.exec = dir =>
new Promise(resolve => {
exec(dir).next();
resolve();
});
module.exports.execSync = execSync;