npmci/dist/npmci.install.js

54 lines
4.3 KiB
JavaScript

"use strict";
const plugins = require("./npmci.plugins");
const configModule = require("./npmci.config");
const npmci_bash_1 = require("./npmci.bash");
const npmci_bash_2 = require("./npmci.bash");
exports.install = (versionArg) => {
let done = plugins.q.defer();
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 (npmci_bash_2.nvmAvailable) {
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!');
}
;
npmci_bash_1.bash('node -v');
npmci_bash_1.bash('npm -v');
// lets look for further config
configModule.getConfig()
.then(configArg => {
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 = 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`);
npmci_bash_1.bash(`npm install ${npmTool} -q -g`);
}
}
plugins.beautylog.success('all global npm tools specified in npmextra.json are now available!');
done.resolve();
});
return done.promise;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtY2kuaW5zdGFsbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWNpLmluc3RhbGwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDJDQUEwQztBQUMxQywrQ0FBOEM7QUFDOUMsNkNBQWdEO0FBQ2hELDZDQUEyQztBQUNoQyxRQUFBLE9BQU8sR0FBRyxDQUFDLFVBQVU7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