2016-05-30 00:29:30 +00:00
|
|
|
"use strict";
|
2017-03-11 00:10:37 +00:00
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
|
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
|
|
});
|
|
|
|
};
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
2017-05-19 10:09:33 +00:00
|
|
|
const plugins = require("./mod.plugins");
|
|
|
|
const configModule = require("../npmci.config");
|
|
|
|
const npmci_bash_1 = require("../npmci.bash");
|
2017-03-11 00:10:37 +00:00
|
|
|
/**
|
|
|
|
* Install a specific version of node
|
|
|
|
* @param versionArg
|
|
|
|
*/
|
|
|
|
exports.install = (versionArg) => __awaiter(this, void 0, void 0, function* () {
|
2016-09-04 11:42:22 +00:00
|
|
|
plugins.beautylog.log(`now installing node version ${versionArg}`);
|
2016-07-18 14:56:53 +00:00
|
|
|
let version;
|
2016-11-15 20:57:18 +00:00
|
|
|
if (versionArg === 'stable') {
|
|
|
|
version = 'stable';
|
2016-06-29 21:18:51 +00:00
|
|
|
}
|
2016-11-15 20:57:18 +00:00
|
|
|
else if (versionArg === 'lts') {
|
|
|
|
version = '6';
|
2016-05-30 00:29:30 +00:00
|
|
|
}
|
2016-11-15 20:57:18 +00:00
|
|
|
else if (versionArg === 'legacy') {
|
2016-11-15 21:47:21 +00:00
|
|
|
version = '6';
|
2016-06-01 03:44:48 +00:00
|
|
|
}
|
2016-05-30 00:29:30 +00:00
|
|
|
else {
|
|
|
|
version = versionArg;
|
|
|
|
}
|
|
|
|
;
|
2017-03-11 13:07:36 +00:00
|
|
|
if (yield npmci_bash_1.nvmAvailable.promise) {
|
2017-03-11 00:10:37 +00:00
|
|
|
yield npmci_bash_1.bash(`nvm install ${version} && nvm alias default ${version}`);
|
2016-08-02 21:11:42 +00:00
|
|
|
plugins.beautylog.success(`Node version ${version} successfully installed!`);
|
|
|
|
}
|
|
|
|
else {
|
2016-11-15 20:57:18 +00:00
|
|
|
plugins.beautylog.warn('Nvm not in path so staying at installed node version!');
|
2016-08-02 21:11:42 +00:00
|
|
|
}
|
|
|
|
;
|
2017-03-11 00:10:37 +00:00
|
|
|
yield npmci_bash_1.bash('node -v');
|
|
|
|
yield npmci_bash_1.bash('npm -v');
|
2016-11-24 22:21:40 +00:00
|
|
|
// lets look for further config
|
2017-03-11 13:07:36 +00:00
|
|
|
yield configModule.getConfig()
|
2017-03-11 00:10:37 +00:00
|
|
|
.then((configArg) => __awaiter(this, void 0, void 0, function* () {
|
2016-12-10 22:27:34 +00:00
|
|
|
plugins.beautylog.log('Now checking for needed global npm tools...');
|
2016-12-10 21:28:27 +00:00
|
|
|
for (let npmTool of configArg.globalNpmTools) {
|
|
|
|
plugins.beautylog.info(`Checking for global "${npmTool}"`);
|
2017-03-11 00:10:37 +00:00
|
|
|
let whichOutput = yield npmci_bash_1.bashNoError(`which ${npmTool}`);
|
2016-12-15 00:08:54 +00:00
|
|
|
let toolAvailable = !((/not\sfound/.test(whichOutput)) || whichOutput === '');
|
2016-11-25 21:34:28 +00:00
|
|
|
if (toolAvailable) {
|
|
|
|
plugins.beautylog.log(`Tool ${npmTool} is available`);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
plugins.beautylog.info(`globally installing ${npmTool} from npm`);
|
2017-03-11 14:17:24 +00:00
|
|
|
if (yield npmci_bash_1.yarnAvailable.promise) {
|
2017-03-11 13:07:36 +00:00
|
|
|
yield npmci_bash_1.bash(`yarn global add ${npmTool}`);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
yield npmci_bash_1.bash(`npm install ${npmTool} -q -g`);
|
|
|
|
}
|
2016-11-25 21:34:28 +00:00
|
|
|
}
|
2016-11-24 22:21:40 +00:00
|
|
|
}
|
2016-12-10 22:27:34 +00:00
|
|
|
plugins.beautylog.success('all global npm tools specified in npmextra.json are now available!');
|
2017-03-11 00:10:37 +00:00
|
|
|
}));
|
|
|
|
});
|
2017-05-19 10:09:33 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9tb2RfaW5zdGFsbC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUEseUNBQXdDO0FBQ3hDLGdEQUErQztBQUMvQyw4Q0FJc0M7QUFFdEM7OztHQUdHO0FBQ1EsUUFBQSxPQUFPLEdBQUcsQ0FBTyxVQUFVO0lBQ3BDLE9BQU8sQ0FBQyxTQUFTLENBQUMsR0FBRyxDQUFDLCtCQUErQixVQUFVLEVBQUUsQ0FBQyxDQUFBO0lBQ2xFLElBQUksT0FBZSxDQUFBO0lBQ25CLEVBQUUsQ0FBQyxDQUFDLFVBQVUsS0FBSyxRQUFRLENBQUMsQ0FBQyxDQUFDO1FBQzVCLE9BQU8sR0FBRyxRQUFRLENBQUE7SUFDcEIsQ0FBQztJQUFDLElBQUksQ0FBQyxFQUFFLENBQUMsQ0FBQyxVQUFVLEtBQUssS0FBSyxDQUFDLENBQUMsQ0FBQztRQUNoQyxPQUFPLEdBQUcsR0FBRyxDQUFBO0lBQ2YsQ0FBQztJQUFDLElBQUksQ0FBQyxFQUFFLENBQUMsQ0FBQyxVQUFVLEtBQUssUUFBUSxDQUFDLENBQUMsQ0FBQztRQUNuQyxPQUFPLEdBQUcsR0FBRyxDQUFBO0lBQ2YsQ0FBQztJQUFDLElBQUksQ0FBQyxDQUFDO1FBQ04sT0FBTyxHQUFHLFVBQVUsQ0FBQTtJQUN0QixDQUFDO0lBQUEsQ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