npmci/dist/npmci.bash.js
2016-06-06 23:57:23 +02:00

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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5wbWNpLmJhc2gudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUN4QixJQUFZLE9BQU8sV0FBTSxpQkFBaUIsQ0FBQyxDQUFBO0FBQ2hDLFlBQUksR0FBRyxVQUFDLFVBQWlCLEVBQUMsUUFBWTtJQUFaLHdCQUFZLEdBQVosWUFBWTtJQUM3QyxFQUFFLENBQUEsQ0FB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