Skip to content

Instantly share code, notes, and snippets.

@domjtalbot
Last active December 2, 2016 13:20
Show Gist options
  • Save domjtalbot/dc6e7d5e114b866361e84ce38b5bba8f to your computer and use it in GitHub Desktop.
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
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