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);
}
});
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);
}
}
}
function installDependencies(toBeInstalled) {
if (toBeInstalled.length > 0) {
const npmInstall = util.promisify(npm.commands.install);
return npmInstall(toBeInstalled);
}
}
const normalizeNpmCommand = (command) => async function callNpm(argsArr, options = {}, root) {
const args = command === 'install' ? [root, argsArr] : [argsArr];
await load(options);
return npCall(npm.commands[command], args);
};
npm.load({prefix: dir, loglevel: 'silent', progress: false}, function(err) {
if (err) { throw err; }
npm.commands.run(script, function(runErr) {
if (runErr) { throw runErr; }
});
});
}