Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2020-07-17 04:40:44 +0300
committerisaacs <i@izs.me>2020-07-29 21:53:10 +0300
commitb12859dcb8d5a8389bd676e7e84caaf8c4de21b9 (patch)
tree5c5356f58a741a0efd2c916accc89c06a6d18fe4 /bin/npm-cli.js
parent2eb06f128e67359efaa8d62fb2d412fc8d0cc9d0 (diff)
refactor and test for main cli script
Diffstat (limited to 'bin/npm-cli.js')
-rwxr-xr-xbin/npm-cli.js69
1 files changed, 1 insertions, 68 deletions
diff --git a/bin/npm-cli.js b/bin/npm-cli.js
index 7507ef40a..577abe03e 100755
--- a/bin/npm-cli.js
+++ b/bin/npm-cli.js
@@ -1,69 +1,2 @@
#!/usr/bin/env node
-
-process.title = 'npm'
-
-const {
- checkForBrokenNode,
- checkForUnsupportedNode
-} = require('../lib/utils/unsupported.js')
-
-checkForBrokenNode()
-
-const log = require('npmlog')
-// pause it here so it can unpause when we've loaded the configs
-// and know what loglevel we should be printing.
-log.pause()
-
-checkForUnsupportedNode()
-
-const npm = require('../lib/npm.js')
-const { defs: { shorthands, types } } = require('../lib/config/core.js')
-const errorHandler = require('../lib/utils/error-handler.js')
-const nopt = require('nopt')
-
-// if npm is called as "npmg" or "npm_g", then
-// run in global mode.
-if (process.argv[1][process.argv[1].length - 1] === 'g') {
- process.argv.splice(1, 1, 'npm', '-g')
-}
-
-log.verbose('cli', process.argv)
-
-const conf = nopt(types, shorthands)
-npm.argv = conf.argv.remain
-
-if (conf.version) {
- console.log(npm.version)
- return errorHandler.exit(0)
-}
-
-if (conf.versions) {
- npm.argv = ['version']
- conf.usage = false
-}
-
-log.info('using', 'npm@%s', npm.version)
-log.info('using', 'node@%s', process.version)
-
-process.on('uncaughtException', errorHandler)
-process.on('unhandledRejection', errorHandler)
-
-// now actually fire up npm and run the command.
-// this is how to use npm programmatically:
-conf._exit = true
-const updateNotifier = require('../lib/utils/update-notifier.js')
-npm.load(conf, function (er) {
- if (er) return errorHandler(er)
-
- updateNotifier(npm)
-
- const cmd = npm.argv.shift()
- const impl = npm.commands[cmd]
- if (impl) {
- impl(npm.argv, errorHandler)
- } else {
- npm.config.set('usage', false)
- npm.argv.unshift(cmd)
- npm.commands.help(npm.argv, errorHandler)
- }
-})
+require('../lib/cli.js')(process)