Files
agent/packages/usb/shared.js
2018-01-30 21:35:35 +01:00

25 lines
498 B
JavaScript

require('shelljs/global');
function execRetry(command) {
let firstRun = true;
let remainingRetries = 3;
let code;
do {
if (!firstRun) {
console.log(`Retrying ${command}`)
}
config.fatal = !remainingRetries;
code = exec(command).code;
config.fatal = true;
firstRun = false;
} while(code && --remainingRetries);
}
const exp = {
execRetry,
}
Object.keys(exp).forEach(function (cmd) {
global[cmd] = exp[cmd];
});