2016-05-30 01:40:07 +00:00
|
|
|
"use strict";
|
|
|
|
require("typings-global");
|
|
|
|
var plugins = require("./npmci.plugins");
|
2016-06-05 18:51:13 +00:00
|
|
|
exports.bash = function (commandArg, retryArg) {
|
|
|
|
if (retryArg === void 0) { retryArg = 2; }
|
2016-06-05 12:55:08 +00:00
|
|
|
if (!process.env.NPMTS_TEST) {
|
2016-06-05 18:51:13 +00:00
|
|
|
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) {
|
2016-06-05 20:51:59 +00:00
|
|
|
i = retryArg + 1; // if everything works out ok retrials are not wanted
|
2016-06-05 18:51:13 +00:00
|
|
|
}
|
2016-06-05 19:11:30 +00:00
|
|
|
else {
|
|
|
|
plugins.beautylog.warn("Something went wrong! Exit Code: " + exitCode.toString);
|
2016-06-06 21:53:14 +00:00
|
|
|
plugins.beautylog.info("Retry " + (i + 1).toString() + " of " + retryArg.toString());
|
2016-06-05 19:11:30 +00:00
|
|
|
}
|
2016-06-05 12:55:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
plugins.beautylog.log("ShellExec would be: " + commandArg.blue);
|
|
|
|
}
|
|
|
|
};
|
2016-06-05 18:51:13 +00:00
|
|
|
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) {
|
2016-06-05 18:51:13 +00:00
|
|
|
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) {
|
2016-06-05 20:51:59 +00:00
|
|
|
i = retryArg + 1; // if everything works out ok retrials are not wanted
|
2016-06-05 18:51:13 +00:00
|
|
|
}
|
2016-06-05 19:11:30 +00:00
|
|
|
else {
|
|
|
|
plugins.beautylog.warn("Something went wrong! Exit Code: " + exitCode.toString);
|
2016-06-06 21:53:14 +00:00
|
|
|
plugins.beautylog.info("Retry " + (i + 1).toString() + " of " + retryArg.toString());
|
2016-06-05 19:11:30 +00:00
|
|
|
}
|
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
|
|
|
};
|
|
|
|
|
2016-06-06 21:53:14 +00:00
|
|
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5wbWNpLmJhc2gudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUN4QixJQUFZLE9BQU8sV0FBTSxpQkFBaUIsQ0FBQyxDQUFBO0FBQ2hDLFlBQUksR0FBRyxVQUFDLFVBQWlCLEVBQUMsUUFBWTtJQUFaLHdCQUFZLEdBQVosWUFBWTtJQUM3QyxFQUFFLENBQUEsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsVUFBVSxDQUFDLENBQUEsQ0FBQztRQUN4QixHQUFHLENBQUMsQ0FBQyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsQ0FBQyxJQUFJLFFBQVEsRUFBRSxDQUFDLEVBQUUsRUFBQyxDQUFDO1lBQ2hDLElBQUksUUFBUSxHQUFVLE9BQU8sQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUN0QywyQ0FBMkM7Z0JBQzNDLFVBQVU7Z0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nRvU3RyaW5nKCkgKyBcIiBvZiBcIiArICByZXRyeUFyZy50b1N0cmluZygpKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH0gZWxzZSB7XG4gICAgICAgIHBsdWdpbnMuYmVhdXR5bG9nLmxvZyhcIlNoZWxsRXhlYyB3b3VsZCBiZTogXCIgKyBjb21tYW5kQXJnLmJsdWUpXG4gICAgfVxufVxuXG5leHBvcnQgbGV0IGJhc2hCYXJlID0gKGNvbW1hbmRBcmcscmV0
|