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