added automatic retrial of failed commands
This commit is contained in:
parent
2ae6fad2a1
commit
1e9c2c850c
4
dist/npmci.bash.d.ts
vendored
4
dist/npmci.bash.d.ts
vendored
@ -1,3 +1,3 @@
|
||||
import "typings-global";
|
||||
export declare let bash: (commandArg: any) => void;
|
||||
export declare let bashBare: (commandArg: any) => void;
|
||||
export declare let bash: (commandArg: string, retryArg?: number) => void;
|
||||
export declare let bashBare: (commandArg: any, retryArg?: number) => void;
|
||||
|
34
dist/npmci.bash.js
vendored
34
dist/npmci.bash.js
vendored
@ -1,24 +1,36 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
var plugins = require("./npmci.plugins");
|
||||
exports.bash = function (commandArg) {
|
||||
exports.bash = function (commandArg, retryArg) {
|
||||
if (retryArg === void 0) { retryArg = 2; }
|
||||
if (!process.env.NPMTS_TEST) {
|
||||
var exitCode = plugins.shelljs.exec("bash -c \"source /usr/local/nvm/nvm.sh &&" +
|
||||
commandArg +
|
||||
"\"").code;
|
||||
if (exitCode !== 0) {
|
||||
process.exit(1);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
plugins.beautylog.log("ShellExec would be: " + commandArg.blue);
|
||||
}
|
||||
};
|
||||
exports.bashBare = function (commandArg) {
|
||||
exports.bashBare = function (commandArg, retryArg) {
|
||||
if (retryArg === void 0) { retryArg = 3; }
|
||||
if (!process.env.NPMTS_TEST) {
|
||||
var exitCode = plugins.shelljs.exec(commandArg).code;
|
||||
if (exitCode !== 0) {
|
||||
process.exit(1);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -26,4 +38,4 @@ exports.bashBare = function (commandArg) {
|
||||
}
|
||||
};
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5wbWNpLmJhc2gudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUN4QixJQUFZLE9BQU8sV0FBTSxpQkFBaUIsQ0FBQyxDQUFBO0FBQ2hDLFlBQUksR0FBRyxVQUFDLFVBQVU7SUFDekIsRUFBRSxDQUFBLENBQUMsQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLFVBQVUsQ0FBQyxDQUFBLENBQUM7UUFDeEIsSUFBSSxRQUFRLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQy9CLDJDQUEyQztZQUMzQyxVQUFVO1lBQ1YsSUFBSSxDQUNQLENBQUMsSUFBSSxDQUFDO1FBQ1AsRUFBRSxDQUFBLENBQUMsUUFBUSxLQUFLLENBQUMsQ0FBQyxDQUFBLENBQUM7WUFDZixPQUFPLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQ3BCLENBQUM7SUFDTCxDQUFDO0lBQUMsSUFBSSxDQUFDLENBQUM7UUFDSixPQUFPLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQyxzQkFBc0IsR0FBRyxVQUFVLENBQUMsSUFBSSxDQUFDLENBQUE7SUFDbkUsQ0FBQztBQUNMLENBQUMsQ0FBQTtBQUVVLGdCQUFRLEdBQUcsVUFBQyxVQUFVO0lBQzdCLEVBQUUsQ0FBQyxDQUFDLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxVQUFVLENBQUMsQ0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FyZyl7XHJcbiAgICAgICAgICAgICAgICBwcm9jZXNzLmV4aXQoMSk7XHJcbiAgICAgICAgICAgIH0gZWxzZSBpZihleGl0Q29kZSA9PSAwKXtcclxuICAgICAgICAgICAgICAgIGkgPSByZXRyeUFyZyArIDE7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICB9IGVsc2Uge1xyXG4gICAgICAgIHBsdWdpbnMuYmVhdXR5bG9nLmxvZyhcIlNoZWxsRXhlYyB3b3VsZCBiZTogXCIgKyBjb21tYW5kQXJnLmJsdWUpXHJcbiAgICB9XHJcbn1cclxuXHJcbmV4cG9ydCBsZXQgYmFzaEJhcmUgPSAoY29tbWFuZEFyZyxyZXRyeUFyZyA9IDMpID0+IHtcclxuICAgIGlmICghcHJvY2Vzcy5lbnYuTlBNVFNfVEVTVCl7XHJcbiAgICAgICAgZm9yKGxldCBpID0gMDsgaSA8PSByZXRyeUFyZzsgaSsrKXtcclxuICAgICAgICAgICAgbGV0IGV4aXRDb2RlID0gcGx1Z2lucy5zaGVsbGpzLmV4ZWMoY29tbWFuZEFyZykuY29kZTtcclxuICAgICAgICAgICAgaWYoZXhpdENvZGUgIT09IDAgJiYgaSA9PSByZXRyeUFyZyl7XHJcbiAgICAgICAgICAgICAgICBwcm9jZXNzLmV4aXQoMSk7XHJcbiAgICAgICAgICAgIH0gZWxzZSBpZihleGl0Q29kZSA9PSAwKXtcclxuICAgICAgICAgICAgICAgIGkgPSByZXRyeUFyZyArIDE7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICB9IGVsc2Uge1xyXG4gICAgICAgIHBsdWdpbnMuYmVhdXR5bG9nLmxvZyhcIlNoZWxsRXhlYyB3b3VsZCBiZTogXCIgKyBjb21tYW5kQXJnLmJsdWUpXHJcbiAgICB9XHJcbn0iXX0=
|
||||
|
@ -1,25 +1,33 @@
|
||||
import "typings-global";
|
||||
import * as plugins from "./npmci.plugins";
|
||||
export let bash = (commandArg) => {
|
||||
export let bash = (commandArg:string,retryArg = 2) => {
|
||||
if(!process.env.NPMTS_TEST){
|
||||
let exitCode = plugins.shelljs.exec(
|
||||
"bash -c \"source /usr/local/nvm/nvm.sh &&" +
|
||||
commandArg +
|
||||
"\""
|
||||
).code;
|
||||
if(exitCode !== 0){
|
||||
process.exit(1);
|
||||
for (let i = 0; i <= retryArg; i++){
|
||||
let 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;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugins.beautylog.log("ShellExec would be: " + commandArg.blue)
|
||||
}
|
||||
}
|
||||
|
||||
export let bashBare = (commandArg) => {
|
||||
export let bashBare = (commandArg,retryArg = 3) => {
|
||||
if (!process.env.NPMTS_TEST){
|
||||
let exitCode = plugins.shelljs.exec(commandArg).code;
|
||||
if(exitCode !== 0){
|
||||
process.exit(1);
|
||||
for(let i = 0; i <= retryArg; i++){
|
||||
let exitCode = plugins.shelljs.exec(commandArg).code;
|
||||
if(exitCode !== 0 && i == retryArg){
|
||||
process.exit(1);
|
||||
} else if(exitCode == 0){
|
||||
i = retryArg + 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugins.beautylog.log("ShellExec would be: " + commandArg.blue)
|
||||
|
Loading…
Reference in New Issue
Block a user