npmci/dist/npmci.bash.js

50 lines
6.8 KiB
JavaScript
Raw Permalink Normal View History

2016-05-30 01:40:07 +00:00
"use strict";
require("typings-global");
var plugins = require("./npmci.plugins");
exports.bash = function (commandArg, retryArg) {
if (retryArg === void 0) { retryArg = 2; }
2016-06-05 12:55:08 +00:00
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
}
2016-06-05 19:11:30 +00:00
else {
plugins.beautylog.warn("Something went wrong! Exit Code: " + exitCode.toString);
plugins.beautylog.info("Retry " + (i + 1).toString + " of " + retryArg.toString);
}
2016-06-05 12:55:08 +00:00
}
}
else {
plugins.beautylog.log("ShellExec would be: " + commandArg.blue);
}
};
exports.bashBare = function (commandArg, retryArg) {
2016-06-05 19:11:30 +00:00
if (retryArg === void 0) { retryArg = 2; }
2016-06-05 12:55:08 +00:00
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
}
2016-06-05 19:11:30 +00:00
else {
plugins.beautylog.warn("Something went wrong! Exit Code: " + exitCode.toString);
plugins.beautylog.info("Retry " + (i + 1).toString + " of " + retryArg.toString);
}
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-05-30 01:40:07 +00:00
};
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5wbWNpLmJhc2gudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0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JiYgaSA9PSByZXRyeUFyZyl7XHJcbiAgICAgICAgICAgICAgICBwcm9jZXNzLmV4aXQoMSk7XHJcbiAgICAgICAgICAgIH0gZWxzZSBpZihleGl0Q29kZSA9PSAwKXtcclxuICAgICAgICAgICAgICAgIGkgPSByZXRyeUFyZyArIDE7IC8vIGlmIGV2ZXJ5dGhpbmcgd29ya3Mgb3V0IG9rIHJldHJpYWxzIGFyZSBub3Qgd2FudGVkXHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBwbHVnaW5zLmJlYXV0eWxvZy53YXJuKFwiU29tZXRoaW5nIHdlbnQgd3JvbmchIEV4aXQgQ29kZTogXCIgKyBleGl0Q29kZS50b1N0cmluZyk7XHJcbiAgICAgICAgICAgICAgICBwbHVnaW5zLmJlYXV0eWxvZy5pbmZvKFwiUmV0cnkgXCIgKyAoaSArIDEpLnRvU3RyaW5nICsgXCIgb2YgXCIgKyAgcmV0cnlBcmcudG9TdHJpbmcpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgfSBlbHNlIHtcclxuICAgICAgICBwbHVnaW5zLmJlYXV0eWxvZy5sb2coXCJTaGVsbEV4ZWMgd291bGQgYmU6IFwiICsgY29tbWFuZEFyZy5ibHVlKVxyXG4gICAgfVxyXG59XHJcblxyXG5leHBvcnQgbGV0IGJh