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

50 lines
6.7 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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