update usage of yarn

This commit is contained in:
2017-03-11 14:07:36 +01:00
parent 8075281499
commit 129d22b537
7 changed files with 79 additions and 22 deletions

View File

@@ -1,7 +1,10 @@
import * as plugins from './npmci.plugins'
import * as configModule from './npmci.config'
import { bash, bashNoError } from './npmci.bash'
import { nvmAvailable } from './npmci.bash'
import {
bash,
bashNoError,
nvmAvailable,
yarnAvailable } from './npmci.bash'
/**
* Install a specific version of node
@@ -28,7 +31,7 @@ export let install = async (versionArg) => {
await bash('node -v')
await bash('npm -v')
// lets look for further config
configModule.getConfig()
await configModule.getConfig()
.then(async configArg => {
plugins.beautylog.log('Now checking for needed global npm tools...')
for (let npmTool of configArg.globalNpmTools) {
@@ -39,7 +42,11 @@ export let install = async (versionArg) => {
plugins.beautylog.log(`Tool ${npmTool} is available`)
} else {
plugins.beautylog.info(`globally installing ${npmTool} from npm`)
await bash(`npm install ${npmTool} -q -g`)
if (await yarnAvailable) {
await bash(`yarn global add ${npmTool}`)
} else {
await bash(`npm install ${npmTool} -q -g`)
}
}
}
plugins.beautylog.success('all global npm tools specified in npmextra.json are now available!')