2016-05-30 01:40:07 +00:00
|
|
|
import "typings-global";
|
|
|
|
import * as plugins from "./npmci.plugins";
|
2016-06-05 18:51:13 +00:00
|
|
|
export let bash = (commandArg:string,retryArg = 2) => {
|
2016-06-05 12:55:08 +00:00
|
|
|
if(!process.env.NPMTS_TEST){
|
2016-06-05 18:51:13 +00:00
|
|
|
for (let i = 0; i <= retryArg; i++){
|
2016-06-05 19:11:30 +00:00
|
|
|
let exitCode:number = plugins.shelljs.exec(
|
2016-06-05 18:51:13 +00:00
|
|
|
"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 19:11:30 +00:00
|
|
|
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);
|
2016-06-05 18:51:13 +00:00
|
|
|
}
|
2016-06-05 12:55:08 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
plugins.beautylog.log("ShellExec would be: " + commandArg.blue)
|
2016-05-30 01:43:15 +00:00
|
|
|
}
|
2016-06-05 12:33:59 +00:00
|
|
|
}
|
|
|
|
|
2016-06-05 19:11:30 +00:00
|
|
|
export let bashBare = (commandArg,retryArg = 2) => {
|
2016-06-05 12:55:08 +00:00
|
|
|
if (!process.env.NPMTS_TEST){
|
2016-06-05 18:51:13 +00:00
|
|
|
for(let i = 0; i <= retryArg; i++){
|
2016-06-05 19:11:30 +00:00
|
|
|
let exitCode:number = plugins.shelljs.exec(commandArg).code;
|
2016-06-05 18:51:13 +00:00
|
|
|
if(exitCode !== 0 && i == retryArg){
|
|
|
|
process.exit(1);
|
|
|
|
} else if(exitCode == 0){
|
2016-06-05 19:11:30 +00:00
|
|
|
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);
|
2016-06-05 18:51:13 +00:00
|
|
|
}
|
2016-06-05 12:55:08 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
plugins.beautylog.log("ShellExec would be: " + commandArg.blue)
|
|
|
|
}
|
2016-05-30 01:40:07 +00:00
|
|
|
}
|