68 lines
5.4 KiB
JavaScript
68 lines
5.4 KiB
JavaScript
"use strict";
|
|
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 });
|
|
const plugins = require("./npmci.plugins");
|
|
const configModule = require("./npmci.config");
|
|
const npmci_bash_1 = require("./npmci.bash");
|
|
/**
|
|
* Install a specific version of node
|
|
* @param versionArg
|
|
*/
|
|
exports.install = (versionArg) => __awaiter(this, void 0, void 0, function* () {
|
|
plugins.beautylog.log(`now installing node version ${versionArg}`);
|
|
let version;
|
|
if (versionArg === 'stable') {
|
|
version = 'stable';
|
|
}
|
|
else if (versionArg === 'lts') {
|
|
version = '6';
|
|
}
|
|
else if (versionArg === 'legacy') {
|
|
version = '6';
|
|
}
|
|
else {
|
|
version = versionArg;
|
|
}
|
|
;
|
|
if (yield npmci_bash_1.nvmAvailable.promise) {
|
|
yield npmci_bash_1.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!');
|
|
}
|
|
;
|
|
yield npmci_bash_1.bash('node -v');
|
|
yield npmci_bash_1.bash('npm -v');
|
|
// lets look for further config
|
|
yield configModule.getConfig()
|
|
.then((configArg) => __awaiter(this, void 0, void 0, function* () {
|
|
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 = yield npmci_bash_1.bashNoError(`which ${npmTool}`);
|
|
let toolAvailable = !((/not\sfound/.test(whichOutput)) || whichOutput === '');
|
|
if (toolAvailable) {
|
|
plugins.beautylog.log(`Tool ${npmTool} is available`);
|
|
}
|
|
else {
|
|
plugins.beautylog.info(`globally installing ${npmTool} from npm`);
|
|
if (yield npmci_bash_1.yarnAvailable.promise) {
|
|
yield npmci_bash_1.bash(`yarn global add ${npmTool}`);
|
|
}
|
|
else {
|
|
yield npmci_bash_1.bash(`npm install ${npmTool} -q -g`);
|
|
}
|
|
}
|
|
}
|
|
plugins.beautylog.success('all global npm tools specified in npmextra.json are now available!');
|
|
}));
|
|
});
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtY2kuaW5zdGFsbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWNpLmluc3RhbGwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7OztBQUFBLDJDQUEwQztBQUMxQywrQ0FBOEM7QUFDOUMsNkNBSXFDO0FBRXJDOzs7R0FHRztBQUNRLFFBQUEsT0FBTyxHQUFHLENBQU8sVUFBVTtJQUNwQyxPQUFPLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQywrQkFBK0IsVUFBVSxFQUFFLENBQUMsQ0FBQTtJQUNsRSxJQUFJLE9BQWUsQ0FBQTtJQUNuQixFQUFFLENBQUMsQ0FBQyxVQUFVLEtBQUssUUFBUSxDQUFDLENBQUMsQ0FBQztRQUM1QixPQUFPLEdBQUcsUUFBUSxDQUFBO0lBQ3BCLENBQUM7SUFBQyxJQUFJLENBQUMsRUFBRSxDQUFDLENBQUMsVUFBVSxLQUFLLEtBQUssQ0FBQyxDQUFDLENBQUM7UUFDaEMsT0FBTyxHQUFHLEdBQUcsQ0FBQTtJQUNmLENBQUM7SUFBQyxJQUFJLENBQUMsRUFBRSxDQUFDLENBQUMsVUFBVSxLQUFL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