-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.js
More file actions
37 lines (34 loc) · 793 Bytes
/
util.js
File metadata and controls
37 lines (34 loc) · 793 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
36
37
import child_process from "child_process";
const exec = function (cmd, cb) {
var p = child_process.exec(cmd);
p.on("exit", function (code) {
var err = null;
if (code) {
err = new Error(
'command "' + cmd + '" exited with wrong status code "' + code + '"'
);
err.code = code;
err.cmd = cmd;
}
if (cb) cb(err);
});
};
// execute multiple commands in series
export const execSeriesOfCommands = function (cmds, cb) {
var execNext = function () {
exec(cmds.shift(), function (err) {
if (err) {
cb(err);
} else {
if (cmds.length) execNext();
else cb(null);
}
});
};
execNext();
};
export const sleep = (ms) => {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
};