now checking if tool already installed

This commit is contained in:
2016-11-25 22:34:28 +01:00
parent 9822a9c867
commit 77a4cd7a12
5 changed files with 20 additions and 9 deletions

View File

@ -13,7 +13,7 @@ let checkNvm = () => {
}
checkNvm()
export let bash = (commandArg: string, retryArg = 2, bareArg = false) => {
export let bash = (commandArg: string, retryArg = 2, bareArg = false): string => {
let exitCode: number
let stdOut: string
let execResult

View File

@ -8,7 +8,6 @@ export interface INpmciOptions {
}
export let getConfig = () => {
console.log('getting config')
let done = q.defer<INpmciOptions>()
let npmciNpmextra = new plugins.npmextra.Npmextra(paths.cwd)
let defaultConfig: INpmciOptions = {

View File

@ -28,8 +28,14 @@ export let install = (versionArg) => {
configModule.getConfig()
.then(config => {
for (let npmTool of config.globalNpmTools) {
plugins.beautylog.info(`globally installing ${npmTool} from npm`)
bash(`npm install -q -g ${npmTool}`)
let whichOutput = bash(`which ${npmTool}`)
let toolAvailable: boolean = !(/not found/.test(whichOutput))
if (toolAvailable) {
plugins.beautylog.log(`Tool ${npmTool} is available`)
} else {
plugins.beautylog.info(`globally installing ${npmTool} from npm`)
bash(`npm install -q -g ${npmTool}`)
}
}
done.resolve()
})