How to use the npm.command function in npm

To help you get started, we’ve selected a few npm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apmjs / apmjs / bin / cli.js View on Github external
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, {
      'install': {
        get: () => require('../src/commands/install.js')
github pimatic / pimatic / ppm.js View on Github external
console.log(npm.version)
  return
}

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", function(err){console.log(err.stack);})

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) {
  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;
  }
github pimatic / pimatic / ppm.js View on Github external
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)
});
github apmjs / apmjs / bin / cli.js View on Github external
'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')
      }
    })

    log.verbose('command:', npm.command)
    npm.commands[npm.command](npm.argv, errorHandler, conf)
  })
})()