update async functions
This commit is contained in:
@@ -2,8 +2,12 @@ import * as plugins from './npmci.plugins'
|
||||
import * as configModule from './npmci.config'
|
||||
import { bash, bashNoError } from './npmci.bash'
|
||||
import { nvmAvailable } from './npmci.bash'
|
||||
export let install = (versionArg) => {
|
||||
let done = plugins.q.defer()
|
||||
|
||||
/**
|
||||
* Install a specific version of node
|
||||
* @param versionArg
|
||||
*/
|
||||
export let install = async (versionArg) => {
|
||||
plugins.beautylog.log(`now installing node version ${versionArg}`)
|
||||
let version: string
|
||||
if (versionArg === 'stable') {
|
||||
@@ -16,30 +20,28 @@ export let install = (versionArg) => {
|
||||
version = versionArg
|
||||
};
|
||||
if (nvmAvailable) {
|
||||
bash(`nvm install ${version} && nvm alias default ${version}`)
|
||||
await bash(`nvm install ${version} && nvm alias default ${version}`)
|
||||
plugins.beautylog.success(`Node version ${version} successfully installed!`)
|
||||
} else {
|
||||
plugins.beautylog.warn('Nvm not in path so staying at installed node version!')
|
||||
};
|
||||
bash('node -v')
|
||||
bash('npm -v')
|
||||
await bash('node -v')
|
||||
await bash('npm -v')
|
||||
// lets look for further config
|
||||
configModule.getConfig()
|
||||
.then(configArg => {
|
||||
.then(async configArg => {
|
||||
plugins.beautylog.log('Now checking for needed global npm tools...')
|
||||
for (let npmTool of configArg.globalNpmTools) {
|
||||
plugins.beautylog.info(`Checking for global "${npmTool}"`)
|
||||
let whichOutput = bashNoError(`which ${npmTool}`)
|
||||
let whichOutput: string = await bashNoError(`which ${npmTool}`)
|
||||
let toolAvailable: boolean = !((/not\sfound/.test(whichOutput)) || whichOutput === '')
|
||||
if (toolAvailable) {
|
||||
plugins.beautylog.log(`Tool ${npmTool} is available`)
|
||||
} else {
|
||||
plugins.beautylog.info(`globally installing ${npmTool} from npm`)
|
||||
bash(`npm install ${npmTool} -q -g`)
|
||||
await bash(`npm install ${npmTool} -q -g`)
|
||||
}
|
||||
}
|
||||
plugins.beautylog.success('all global npm tools specified in npmextra.json are now available!')
|
||||
done.resolve()
|
||||
})
|
||||
return done.promise
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user