fix npm global Tool installation

This commit is contained in:
Philipp Kunz 2016-12-10 22:43:14 +01:00
parent b194bf2a0e
commit 787145816a
5 changed files with 51 additions and 13 deletions

12
dist/npmci.bash.d.ts vendored
View File

@ -1,3 +1,13 @@
export declare let nvmAvailable: boolean;
/**
* bash() allows using bash with nvm in path
*/
export declare let bash: (commandArg: string, retryArg?: number, bareArg?: boolean) => string;
export declare let bashBare: (commandArg: any, retryArg?: number) => string;
/**
* bashBare allows usage of bash without sourcing any files like nvm
*/
export declare let bashBare: (commandArg: string, retryArg?: number) => string;
/**
* bashNoError allows executing stuff without throwing an error
*/
export declare let bashNoError: (commandArg: string) => string;

19
dist/npmci.bash.js vendored
View File

@ -14,6 +14,9 @@ let checkNvm = () => {
;
};
checkNvm();
/**
* bash() allows using bash with nvm in path
*/
exports.bash = (commandArg, retryArg = 2, bareArg = false) => {
let exitCode;
let stdOut;
@ -28,11 +31,12 @@ exports.bash = (commandArg, retryArg = 2, bareArg = false) => {
}
exitCode = execResult.code;
stdOut = execResult.stdout;
// determine how bash reacts to error and success
if (exitCode !== 0 && i === retryArg) {
process.exit(1);
}
else if (exitCode === 0) {
i = retryArg + 1; // if everything works out ok retrials are not wanted
else if (exitCode === 0 || retryArg === -1) {
i = retryArg + 1; // retry +1 breaks for loop, if everything works out ok retrials are not wanted
}
else {
plugins.beautylog.warn('Something went wrong! Exit Code: ' + exitCode.toString());
@ -45,7 +49,16 @@ exports.bash = (commandArg, retryArg = 2, bareArg = false) => {
}
return stdOut;
};
/**
* bashBare allows usage of bash without sourcing any files like nvm
*/
exports.bashBare = (commandArg, retryArg = 2) => {
return exports.bash(commandArg, retryArg, true);
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtY2kuYmFzaC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWNpLmJhc2gudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDJDQ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SxHQUFHLFFBQVEsQ0FBQyxRQUFRLEVBQUUsQ0FBQyxDQUFBO1lBQ3hGLENBQUM7UUFDTCxDQUFDO0lBQ0wsQ0FBQztJQUFDLElBQUksQ0FBQyxDQUFDO1FBQ0osT0FBTyxDQUFDLFNBQVMsQ0FBQyxHQUFHLENBQUMsc0JBQXNCLEdBQUcsVUFBVSxDQUFDLENBQUE7SUFDOUQsQ0FBQztJQUNELE1BQU0sQ0FBQyxNQUFNLENBQUE7QUFDakIsQ0FBQyxDQUFBO0FBRVUsUUFBQSxRQUFRLEdBQUcsQ0FBQyxVQUFVLEVBQUUsUUFBUSxHQUFHLENBQUM7SUFDM0MsTUFBTSxDQUFDLFlBQUksQ0FBQyxVQUFVLEVBQUUsUUFBUSxFQUFFLElBQUksQ0FBQyxDQUFBO0FBQzNDLENBQUMsQ0FBQSJ9
/**
* bashNoError allows executing stuff without throwing an error
*/
exports.bashNoError = (commandArg) => {
return exports.bash(commandArg, -1);
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtY2kuYmFzaC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWNpLmJhc2gudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDJDQUEwQztBQUUxQyxJQUFJLGVBQWUsR0FBVyxFQUFFLENBQUE7QUFDckIsUUFBQSxZQUFZLEdBQVksS0FBSyxDQUFBO0FBQ3hDLElBQUksUUFBUSxHQUFHO0lBQ1gsRUFBRSxDQUFDLENBQUMsT0FBTyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsd0NBQXdDLEVBQUMsRUFBQyxNQUFNLEVBQUUsSUFBSSxFQUFDLENBQUMsQ0FBQyxJQUFJLEtBQUssQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUMzRixlQUFlLEdBQUcsa0NBQWtDLENBQUE7UUFDcEQsb0JBQVksR0FBRyxJQUFJLENBQUE7S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LENBQUMsVUFBa0IsRUFBRSxXQUFtQixDQUFDO0lBQzNELE1BQU0sQ0FBQyxZQUFJLENBQUMsVUFBVSxFQUFFLFFBQVEsRUFBRSxJQUFJLENBQUMsQ0FBQTtBQUMzQyxDQUFDLENBQUE7QUFFRDs7R0FFRztBQUNRLFFBQUEsV0FBVyxHQUFHLENBQUMsVUFBa0I7SUFDeEMsTUFBTSxDQUFDLFlBQUksQ0FBQyxVQUFVLEVBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQTtBQUM5QixDQUFDLENBQUEifQ==

View File

@ -35,7 +35,7 @@ exports.install = (versionArg) => {
.then(configArg => {
for (let npmTool of configArg.globalNpmTools) {
plugins.beautylog.info(`Checking for global "${npmTool}"`);
let whichOutput = npmci_bash_1.bash(`which ${npmTool}`);
let whichOutput = npmci_bash_1.bashNoError(`which ${npmTool}`);
let toolAvailable = !(/not found/.test(whichOutput));
if (toolAvailable) {
plugins.beautylog.log(`Tool ${npmTool} is available`);
@ -49,4 +49,4 @@ exports.install = (versionArg) => {
});
return done.promise;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtY2kuaW5zdGFsbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWNpLmluc3RhbGwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDJDQUEwQztBQUMxQywrQ0FBOEM7QUFDOUMsNkNBQW1DO0FBQ25DLDZDQUEyQztBQUNoQyxRQUFBLE9BQU8sR0FBRyxDQUFDLFVBQVU7SUFDNUIsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQTtJQUM1QixPQUFPLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQywrQkFBK0IsVUFBVSxFQUFFLENBQUMsQ0FBQTtJQUNsRSxJQUFJLE9BQWUsQ0FBQTtJQUNuQixFQUFFLEN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FJLENBQUMsUUFBUSxDQUFDLENBQUE7SUFFZCwrQkFBK0I7SUFDL0IsWUFBWSxDQUFDLFNBQVMsRUFBRTtTQUNuQixJQUFJLENBQUMsU0FBUztRQUNYLEdBQUcsQ0FBQyxDQUFDLElBQUksT0FBTyxJQUFJLFNBQVMsQ0FBQyxjQUFjLENBQUMsQ0FBQyxDQUFDO1lBQzNDLE9BQU8sQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLHdCQUF3QixPQUFPLEdBQUcsQ0FBQyxDQUFBO1lBQzFELElBQUksV0FBVyxHQUFHLHdCQUFXLENBQUMsU0FBUyxPQUFPLEVBQUUsQ0FBQyxDQUFBO1lBQ2pELElBQUksYUFBYSxHQUFZLENBQUMsQ0FBQyxXQUFXLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxDQUFDLENBQUE7WUFDN0QsRUFBRSxDQUFDLENBQUMsYUFBYSxDQUFDLENBQUMsQ0FBQztnQkFDaEIsT0FBTyxDQUFDLFNBQVMsQ0FBQyxHQUFHLENBQUMsUUFBUSxPQUFPLGVBQWUsQ0FBQyxDQUFBO1lBQ3pELENBQUM7WUFBQyxJQUFJLENBQUMsQ0FBQztnQkFDSixPQUFPLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyx1QkFBdUIsT0FBTyxXQUFXLENBQUMsQ0FBQTtnQkFDakUsaUJBQUksQ0FBQyxlQUFlLE9BQU8sUUFBUSxDQUFDLENBQUE7WUFDeEMsQ0FBQztRQUNMLENBQUM7UUFDRCxJQUFJLENBQUMsT0FBTyxFQUFFLENBQUE7SUFDbEIsQ0FBQyxDQUFDLENBQUE7SUFDTixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQTtBQUN2QixDQUFDLENBQUEifQ==

View File

@ -13,7 +13,10 @@ let checkNvm = () => {
}
checkNvm()
export let bash = (commandArg: string, retryArg = 2, bareArg = false): string => {
/**
* bash() allows using bash with nvm in path
*/
export let bash = (commandArg: string, retryArg: number = 2, bareArg: boolean = false): string => {
let exitCode: number
let stdOut: string
let execResult
@ -28,10 +31,12 @@ export let bash = (commandArg: string, retryArg = 2, bareArg = false): string =>
}
exitCode = execResult.code
stdOut = execResult.stdout
if (exitCode !== 0 && i === retryArg) {
// determine how bash reacts to error and success
if (exitCode !== 0 && i === retryArg) { // something went wrong and retries are exhausted
process.exit(1)
} else if (exitCode === 0) {
i = retryArg + 1 // if everything works out ok retrials are not wanted
} else if (exitCode === 0 || retryArg === -1) { // everything went fine, or no error wanted
i = retryArg + 1 // retry +1 breaks for loop, 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())
@ -43,6 +48,16 @@ export let bash = (commandArg: string, retryArg = 2, bareArg = false): string =>
return stdOut
}
export let bashBare = (commandArg, retryArg = 2) => {
/**
* bashBare allows usage of bash without sourcing any files like nvm
*/
export let bashBare = (commandArg: string, retryArg: number = 2) => {
return bash(commandArg, retryArg, true)
}
/**
* bashNoError allows executing stuff without throwing an error
*/
export let bashNoError = (commandArg: string) => {
return bash(commandArg,-1)
}

View File

@ -1,6 +1,6 @@
import * as plugins from './npmci.plugins'
import * as configModule from './npmci.config'
import { bash } from './npmci.bash'
import { bash, bashNoError } from './npmci.bash'
import { nvmAvailable } from './npmci.bash'
export let install = (versionArg) => {
let done = plugins.q.defer()
@ -29,7 +29,7 @@ export let install = (versionArg) => {
.then(configArg => {
for (let npmTool of configArg.globalNpmTools) {
plugins.beautylog.info(`Checking for global "${npmTool}"`)
let whichOutput = bash(`which ${npmTool}`)
let whichOutput = bashNoError(`which ${npmTool}`)
let toolAvailable: boolean = !(/not found/.test(whichOutput))
if (toolAvailable) {
plugins.beautylog.log(`Tool ${npmTool} is available`)