OS X changes

This commit is contained in:
Scott E. Graves
2018-11-08 12:47:52 -06:00
parent f7574c0815
commit acfeb4a9a2
5 changed files with 97 additions and 99 deletions

View File

@@ -125,7 +125,7 @@ module.exports.executeAndWait = command => {
});
};
module.exports.executeAsync = (command) => {
module.exports.executeAsync = (command, args=[]) => {
return new Promise((resolve, reject) => {
const launchProcess = (count, timeout) => {
const processOptions = {
@@ -133,7 +133,7 @@ module.exports.executeAsync = (command) => {
shell: true,
};
const process = new spawn(command, [], processOptions);
const process = new spawn(command, args, processOptions);
const pid = process.pid;
process.on('error', (err) => {
@@ -146,10 +146,13 @@ module.exports.executeAsync = (command) => {
});
process.on('exit', (code) => {
if (++count === 5) {
reject(code, pid);
} else {
setTimeout(()=>launchProcess(count, setTimeout(() => resolve(), 3000)), 1000);
if (code !== 0) {
if (++count === 5) {
reject(code, pid);
} else {
clearTimeout(timeout);
setTimeout(() => launchProcess(count, setTimeout(() => resolve(), 3000)), 1000);
}
}
});