Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
npm.load({loglevel: 'silent', lock: false}, (err, success) => {
if (err) {
console.error(err);
}
else {
npmInstall = promisify(npm.commands.install);
npmView = promisify(npm.commands.view);
// disable an attack vector
npm.config.set('ignore-scripts', true);
}
});
npm.load({loglevel: 'silent', lock: false}, (err, success) => {
if (err) {
console.error(err);
}
else {
npmInstall = promisify(npm.commands.install);
npmView = promisify(npm.commands.view);
// disable an attack vector
npm.config.set('ignore-scripts', true);
}
});
npm.load({loglevel: 'silent', lock: false}, (err, success) => {
if (err) {
console.error(err);
}
else {
npmInstall = promisify(npm.commands.install);
npmView = promisify(npm.commands.view);
// disable an attack vector
npm.config.set('ignore-scripts', true);
}
});
callback();
}
}
});
}
});
}
} else {
if (forceInstall) {
// reinstall package module
if (name.indexOf('/') === -1) {
// not a tarball
npm.commands.install(installPath, [name+'@'+version], installCallback);
} else {
// do not specify version for tarball
npm.commands.install(installPath, [name], installCallback);
}
} else {
// check if package is installed
checkInstalled(name.indexOf('/') !== -1);
}
}
}
return function (err, view) {
if (err) {
// reset npm.prefix to saved value
npm.prefix = savedPrefix;
err.code = VIEW_ERR;
return callback(err);
}
// npm view success
var latestVersion = Object.keys(view)[0];
if ((typeof latestVersion !== 'undefined') && (latestVersion === installedVersion)) {
// reset npm.prefix to saved value
npm.prefix = savedPrefix;
return callback();
} else {
npm.commands.install(installPath, [name+'@'+latestVersion], installCallback);
}
}
}
return function (err, view) {
if (err) {
// reset npm.prefix to saved value
npm.prefix = savedPrefix;
err.code = VIEW_ERR;
return callback(err);
}
// npm view success
var latestVersion = Object.keys(view)[0];
if ((typeof latestVersion !== 'undefined') && (latestVersion === installedVersion)) {
// reset npm.prefix to saved value
npm.prefix = savedPrefix;
return callback();
} else {
npm.commands.install(installPath, [name+'@'+latestVersion], installCallback);
}
}
}
function loadCallback(err) {
if (err) {
err.code = LOAD_ERR;
return callback(err);
}
// npm loaded successfully
savedPrefix = npm.prefix; // save current npm.prefix
npm.prefix = installPath; // change npm.prefix to given installPath
if (!name) {
// just want to do an "npm install" where a package.json is
npm.commands.install(installPath, [], installCallback);
} else if (localInstall) {
if (forceInstall) {
// local install won't work with version specified
npm.commands.install(installPath, [name], installCallback);
} else {
// check if there is already a local install of this module
fs.readFile(path.resolve(name, 'package.json'), 'utf8', function (err, sourcePkgData) {
if (err) {
// reset npm.prefix to saved value
npm.prefix = savedPrefix;
callback(err);
function installCallback(err, result) {
// reset npm.prefix to saved value
npm.prefix = savedPrefix;
if (err) {
err.code = INSTALL_ERR;
}
callback(err, result);
}
} else {
// check if package is installed
checkInstalled(name.indexOf('/') !== -1);
}
}
}
npm.load(npmLoad, loadCallback);
};
npmi.LOAD_ERR = LOAD_ERR;
npmi.INSTALL_ERR = INSTALL_ERR;
npmi.VIEW_ERR = VIEW_ERR;
npmi.NPM_VERSION = npm.version;
module.exports = npmi;
if (name.indexOf('/') === -1) {
// not a tarball
npm.commands.install(installPath, [name+'@'+version], installCallback);
} else {
// do not specify version for tarball
npm.commands.install(installPath, [name], installCallback);
}
} else {
// check if package is installed
checkInstalled(name.indexOf('/') !== -1);
}
}
}
npm.load(npmLoad, loadCallback);
};