2016-05-30 01:40:07 +00:00
|
|
|
"use strict";
|
|
|
|
require("typings-global");
|
2016-07-18 14:56:53 +00:00
|
|
|
const plugins = require("./npmci.plugins");
|
|
|
|
exports.bash = (commandArg, retryArg = 2, bareArg = false) => {
|
|
|
|
let exitCode;
|
|
|
|
let stdOut;
|
|
|
|
let execResult;
|
2016-06-05 12:55:08 +00:00
|
|
|
if (!process.env.NPMTS_TEST) {
|
2016-07-18 14:56:53 +00:00
|
|
|
for (let i = 0; i <= retryArg; i++) {
|
2016-06-07 01:59:47 +00:00
|
|
|
if (!bareArg) {
|
|
|
|
execResult = plugins.shelljs.exec("bash -c \"source /usr/local/nvm/nvm.sh &&" +
|
|
|
|
commandArg +
|
2016-06-07 02:55:28 +00:00
|
|
|
"\"");
|
2016-06-05 18:51:13 +00:00
|
|
|
}
|
2016-06-05 19:11:30 +00:00
|
|
|
else {
|
2016-06-07 03:37:02 +00:00
|
|
|
execResult = plugins.shelljs.exec(commandArg);
|
2016-06-05 19:11:30 +00:00
|
|
|
}
|
2016-06-07 01:59:47 +00:00
|
|
|
exitCode = execResult.code;
|
|
|
|
stdOut = execResult.stdout;
|
2016-06-05 18:51:13 +00:00
|
|
|
if (exitCode !== 0 && i == retryArg) {
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
else if (exitCode == 0) {
|
2016-06-05 20:51:59 +00:00
|
|
|
i = retryArg + 1; // if everything works out ok retrials are not wanted
|
2016-06-05 18:51:13 +00:00
|
|
|
}
|
2016-06-05 19:11:30 +00:00
|
|
|
else {
|
2016-06-06 21:57:23 +00:00
|
|
|
plugins.beautylog.warn("Something went wrong! Exit Code: " + exitCode.toString());
|
2016-06-06 21:53:14 +00:00
|
|
|
plugins.beautylog.info("Retry " + (i + 1).toString() + " of " + retryArg.toString());
|
2016-06-05 19:11:30 +00:00
|
|
|
}
|
2016-06-05 12:55:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
plugins.beautylog.log("ShellExec would be: " + commandArg.blue);
|
2016-05-30 01:54:14 +00:00
|
|
|
}
|
2016-06-07 01:59:47 +00:00
|
|
|
return stdOut;
|
|
|
|
};
|
2016-07-18 14:56:53 +00:00
|
|
|
exports.bashBare = (commandArg, retryArg = 2) => {
|
2016-06-07 01:59:47 +00:00
|
|
|
return exports.bash(commandArg, retryArg, true);
|
2016-05-30 01:40:07 +00:00
|
|
|
};
|
2016-07-18 14:56:53 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtY2kuYmFzaC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWNpLmJhc2gudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUN4QixNQUFZLE9BQU8sV0FBTSxpQkFBaUIsQ0FBQyxDQUFBO0FBRWhDLFlBQUksR0FBRyxDQUFDLFVBQWlCLEVBQUMsUUFBUSxHQUFHLENBQUMsRUFBQyxPQUFPLEdBQUcsS0FBSztJQUM3RCxJQUFJLFFBQWUsQ0FBQztJQUNwQixJQUFJLE1BQWEsQ0FBQztJQUNsQixJQUFJLFVBQVUsQ0FBQztJQUNmLEVBQUUsQ0FBQSxDQUFDLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxVQUFVLENBQUMsQ0FBQSxDQUFDO1FBQ3hCLEdBQUcsQ0FBQyxDQUFDLElBQUksQ0FBQyxHQUFHLENBQUMsRUFBRSxDQUFDLElBQUksUUFBUSxFQUFFLENBQUMsRUFBRSxFQUFDLENBQUM7WUFDaEMsRUFBRSxDQUFBLENBQUMsQ0FBQyxPQUFPLENBQUMsQ0FBQSxDQUFDO2dCQUNULFVBQVUsR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FDN0IsMkNBQTJDO29CQUMzQyxVQUFVO29CQUNWLElBQUksQ0FDUCxDQUFDO1lBQ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