Last active
December 2, 2016 13:20
-
-
Save domjtalbot/dc6e7d5e114b866361e84ce38b5bba8f to your computer and use it in GitHub Desktop.
Automate Node version install via NVM
Node version controlled via environment variable NODEVERSION
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { exec } from 'child_process'; | |
import Ora from 'ora'; | |
import './env.es6'; | |
import { Debug } from './debug.es6'; | |
import { green } from 'ansicolors'; | |
const debug = new Debug('node:install'); | |
const version = process.env.NODEVERSION; | |
const cwd = process.cwd(); | |
const installSpinner = new Ora(`Installing node ${version}`); | |
debug(`Installing node ${version}`); | |
installSpinner.start(); | |
exec(`nvm install ${version} && nvm use ${version}`, { | |
cwd, | |
}, (err) => { | |
if (err) { | |
installSpinner.fail(); | |
throw err; | |
} | |
installSpinner.succeed(); | |
debug(green('Done')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment