npmci/dist/npmci.bash.js

50 lines
6.8 KiB
JavaScript

"use strict";
require("typings-global");
var plugins = require("./npmci.plugins");
exports.bash = function (commandArg, retryArg) {
if (retryArg === void 0) { retryArg = 2; }
if (!process.env.NPMTS_TEST) {
for (var i = 0; i <= retryArg; i++) {
var exitCode = plugins.shelljs.exec("bash -c \"source /usr/local/nvm/nvm.sh &&" +
commandArg +
"\"").code;
if (exitCode !== 0 && i == retryArg) {
process.exit(1);
}
else if (exitCode == 0) {
i = retryArg + 1; // if everything works out ok retrials are not wanted
}
else {
plugins.beautylog.warn("Something went wrong! Exit Code: " + exitCode.toString);
plugins.beautylog.info("Retry " + (i + 1).toString + " of " + retryArg.toString);
}
}
}
else {
plugins.beautylog.log("ShellExec would be: " + commandArg.blue);
}
};
exports.bashBare = function (commandArg, retryArg) {
if (retryArg === void 0) { retryArg = 2; }
if (!process.env.NPMTS_TEST) {
for (var i = 0; i <= retryArg; i++) {
var exitCode = plugins.shelljs.exec(commandArg).code;
if (exitCode !== 0 && i == retryArg) {
process.exit(1);
}
else if (exitCode == 0) {
i = retryArg + 1; // if everything works out ok retrials are not wanted
}
else {
plugins.beautylog.warn("Something went wrong! Exit Code: " + exitCode.toString);
plugins.beautylog.info("Retry " + (i + 1).toString + " of " + retryArg.toString);
}
}
}
else {
plugins.beautylog.log("ShellExec would be: " + commandArg.blue);
}
};
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5wbWNpLmJhc2gudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUN4QixJQUFZLE9BQU8sV0FBTSxpQkFBaUIsQ0FBQyxDQUFBO0FBQ2hDLFlBQUksR0FBRyxVQUFDLFVBQWlCLEVBQUMsUUFBWTtJQUFaLHdCQUFZLEdBQVosWUFBWTtJQUM3QyxFQUFFLENBQUEsQ0FBQyxDQUFDLE9BQU8sQ0F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