Merge branch 'master' into 'master'

fix tool Installation and bash without error.

See merge request !1
This commit is contained in:
Phil Kunz 2016-12-14 22:03:00 +00:00
commit ee7e7e2551
2 changed files with 11 additions and 3 deletions

View File

@ -15,11 +15,18 @@ checkNvm()
/**
* bash() allows using bash with nvm in path
* @param commandArg - The command to execute
* @param retryArg - The retryArg: 0 to any positive number will retry, -1 will always succeed, -2 will return undefined
*/
export let bash = (commandArg: string, retryArg: number = 2, bareArg: boolean = false): string => {
let exitCode: number
let stdOut: string
let execResult
let failOnError: boolean = true;
if(retryArg === -1) {
failOnError = false
retryArg = 0
}
if (!process.env.NPMTS_TEST) { // NPMTS_TEST is used during testing
for (let i = 0; i <= retryArg; i++) {
if (!bareArg) {
@ -34,8 +41,10 @@ export let bash = (commandArg: string, retryArg: number = 2, bareArg: boolean =
// 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 || retryArg === -1) { // everything went fine, or no error wanted
if (failOnError) {
process.exit(1)
}
} else if (exitCode === 0) { // 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())

View File

@ -30,7 +30,6 @@ export let install = (versionArg) => {
for (let npmTool of configArg.globalNpmTools) {
plugins.beautylog.info(`Checking for global "${npmTool}"`)
let whichOutput = bashNoError(`which ${npmTool}`)
console.log(whichOutput)
let toolAvailable: boolean = !(/not\sfound/.test(whichOutput))
if (toolAvailable) {
plugins.beautylog.log(`Tool ${npmTool} is available`)