forked from thebeet/idevicekit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexec.js
More file actions
27 lines (25 loc) · 714 Bytes
/
exec.js
File metadata and controls
27 lines (25 loc) · 714 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
let child_process = require('child_process');
let exec = (cmd, args, option) => {
let defaultOption = {
encoding: 'utf8',
timeout: 30000,
maxBuffer: 256*1024*1024,
killSignal: 'SIGTERM',
cwd: null,
env: null
};
if (option) {
let extend = require('extend');
defaultOption = extend(true, defaultOption, option);
}
return new Promise((resolve, reject) => {
child_process.execFile(cmd, args, defaultOption, (err, stdout, stderr) => {
if (err) {
reject(err, stdout, stderr);
} else {
resolve(stdout, stderr);
}
});
});
};
module.exports = exec;