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) {
|
|
|
|
i = retryArg + 1;
|
|
|
|
}
|
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) {
|
|
|
|
if (retryArg === void 0) { retryArg = 3; }
|
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) {
|
|
|
|
i = retryArg + 1;
|
|
|
|
}
|
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-05 18:51:13 +00:00
|
|
|
//# sour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b3J0ICogYXMgcGx1Z2lucyBmcm9tIFwiLi9ucG1jaS5wbHVnaW5zXCI7XHJcbmV4cG9ydCBsZXQgYmFzaCA9IChjb21tYW5kQXJnOnN0cmluZyxyZXRyeUFyZyA9IDIpID0+IHtcclxuICAgIGlmKCFwcm9jZXNzLmVudi5OUE1UU19URVNUKXtcclxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8PSByZXRyeUFyZzsgaSsrKXtcclxuICAgICAgICAgICAgbGV0IGV4aXRDb2RlID0gcGx1Z2lucy5zaGVsbGpzLmV4ZWMoXHJcbiAgICAgICAgICAgICAgICBcImJhc2ggLWMgXFxcInNvdXJjZSAvdXNyL2xvY2FsL252bS9udm0uc2ggJiZcIiArXHJcbiAgICAgICAgICAgICAgICBjb21tYW5kQXJnICtcclxuICAgICAgICAgICAgICAgIFwiXFxcIlwiXHJcbiAgICAgICAgICAgICkuY29kZTtcclxuICAgICAgICAgICAgaWYoZXhpdENvZGUgIT09IDAgJiYgaSA9PSByZXRyeUFyZyl7XHJcbiAgICAgICAgICAgICAgICBwcm9jZXNzLmV4aXQoMSk7XHJcbiAgICAgICAgICAgIH0gZWxzZSBpZihleGl0Q29kZSA9PSAwKXtcclxuICAgICAgICAgICAgICAgIGkgPSByZXRyeUFyZyArIDE7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICB9IGVsc2Uge1xyXG4gICAgICAgIHBsdWdpbnMuYmVhdXR5bG9nLmxvZyhcIlNoZWxsRXhlYyB3b3VsZCBiZTogXCIgKyBjb21tYW5kQXJnLmJsdWUpXHJcbiAgICB9XHJcbn1cclxuXHJcbmV4cG9ydCBsZXQgYmFzaEJhcmUgPSAoY29tbWFuZEFyZyxyZXRyeUFyZyA9IDMpID0+IHtcclxuICAgIGlmICghcHJvY2Vzcy5lbnYuTlBNVFNfVEVTVCl7XHJcbiAgICAgICAgZm9yKGxldCBpID0gMDsgaSA8PSByZXRyeUFyZzsgaSsrKXtcclxuICAgICAg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