Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (conf.version) {
console.log(pkg.version)
return errorHandler.exit(0)
}
if (conf.versions) {
npm.command = 'version'
conf.usage = false
npm.argv = []
}
log.info('using', 'npm@%s', npm.version)
log.info('using', 'node@%s', process.version)
process.on('uncaughtException', errorHandler)
if (conf.usage && npm.command !== 'help') {
npm.argv.unshift(npm.command)
npm.command = 'help'
}
// now actually fire up npm and run the command.
// this is how to use npm programmatically:
conf._exit = true
npm.load(conf, function (er) {
// this log is different from the one required by npm
log.level = npm.config.get('loglevel')
log.resume()
if (er) return errorHandler(er)
Object.defineProperties(npm.commands, {
npm.load(conf, function (er) {
if (er) return errorHandler(er)
// we are patching install with out modified routine
if (npm.command === 'install') {
var install = require('./ppm/install.js');
install(npm.argv, errorHandler);
return;
}
npm.commands[npm.command](npm.argv, errorHandler)
});
npm.load(conf, function (er) {
// this log is different from the one required by npm
log.level = npm.config.get('loglevel')
log.resume()
if (er) return errorHandler(er)
Object.defineProperties(npm.commands, {
'install': {
get: () => require('../src/commands/install.js')
},
'update': {
get: () => require('../src/commands/update.js')
},
'link': {
get: () => require('../src/commands/link.js')
},
'unlink': {
get: () => require('../src/commands/unlink.js')
}
})