npmci/dist/npmci.install.js

52 lines
4.0 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 => {
for (let npmTool of configArg.globalNpmTools) {
plugins.beautylog.info(`Checking for global "${npmTool}"`);
let whichOutput = npmci_bash_1.bashNoError(`which ${npmTool}`);
let toolAvailable = !(/not found/.test(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`);
}
}
done.resolve();
});
return done.promise;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtY2kuaW5zdGFsbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWNpLmluc3RhbGwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDJDQUEwQztBQUMxQywrQ0FBOEM7QUFDOUMsNkNBQWdEO0FBQ2hELDZDQUEyQztBQUNoQyxRQUFBLE9BQU8sR0FBRyxDQUFDLFVBQVU7SUFDNUIsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0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