2016-05-30 00:28:47 +00:00
|
|
|
import "typings-global";
|
|
|
|
import * as plugins from "./npmci.plugins";
|
2016-08-02 21:11:42 +00:00
|
|
|
import { bash } from "./npmci.bash";
|
|
|
|
import { nvmAvailable } from "./npmci.bash"
|
2016-05-30 01:40:07 +00:00
|
|
|
|
2016-05-29 20:54:59 +00:00
|
|
|
export let install = (versionArg) => {
|
2016-05-30 00:28:47 +00:00
|
|
|
let done = plugins.q.defer();
|
2016-09-04 11:42:22 +00:00
|
|
|
plugins.beautylog.log(`now installing node version ${versionArg}`);
|
2016-08-02 21:11:42 +00:00
|
|
|
let version: string;
|
|
|
|
if (versionArg == "stable") {
|
2016-11-14 23:07:55 +00:00
|
|
|
version = "stable";
|
2016-08-02 21:11:42 +00:00
|
|
|
} else if (versionArg == "lts") {
|
2016-11-14 23:07:55 +00:00
|
|
|
version = "--lts";
|
2016-08-02 21:11:42 +00:00
|
|
|
} else if (versionArg == "legacy") {
|
2016-09-20 10:43:37 +00:00
|
|
|
version = "6.6.0"
|
2016-08-02 21:11:42 +00:00
|
|
|
} else {
|
2016-05-30 00:28:47 +00:00
|
|
|
version = versionArg;
|
|
|
|
};
|
2016-08-02 21:11:42 +00:00
|
|
|
if (nvmAvailable) {
|
|
|
|
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!");
|
|
|
|
};
|
2016-05-30 01:53:37 +00:00
|
|
|
bash("node -v");
|
|
|
|
bash("npm -v");
|
2016-05-30 00:28:47 +00:00
|
|
|
done.resolve();
|
|
|
|
return done.promise;
|
2016-05-29 20:54:59 +00:00
|
|
|
}
|