@@ -17,9 +17,7 @@ module.exports = (process) => {
1717 checkForUnsupportedNode ( )
1818
1919 const npm = require ( '../lib/npm.js' )
20- const { defs : { shorthands, types } } = require ( '../lib/config/core.js' )
2120 const errorHandler = require ( '../lib/utils/error-handler.js' )
22- const nopt = require ( 'nopt' )
2321
2422 // if npm is called as "npmg" or "npm_g", then
2523 // run in global mode.
@@ -29,19 +27,6 @@ module.exports = (process) => {
2927
3028 log . verbose ( 'cli' , process . argv )
3129
32- const conf = nopt ( types , shorthands , process . argv )
33- npm . argv = conf . argv . remain
34-
35- if ( conf . version ) {
36- console . log ( npm . version )
37- return errorHandler . exit ( 0 )
38- }
39-
40- if ( conf . versions ) {
41- npm . argv = [ 'version' ]
42- conf . usage = false
43- }
44-
4530 log . info ( 'using' , 'npm@%s' , npm . version )
4631 log . info ( 'using' , 'node@%s' , process . version )
4732
@@ -50,10 +35,18 @@ module.exports = (process) => {
5035
5136 // now actually fire up npm and run the command.
5237 // this is how to use npm programmatically:
53- conf . _exit = true
5438 const updateNotifier = require ( '../lib/utils/update-notifier.js' )
55- npm . load ( conf , async er => {
39+ npm . load ( async er => {
5640 if ( er ) return errorHandler ( er )
41+ if ( npm . config . get ( 'version' , 'cli' ) ) {
42+ console . log ( npm . version )
43+ return errorHandler . exit ( 0 )
44+ }
45+
46+ if ( npm . config . get ( 'versions' , 'cli' ) ) {
47+ npm . argv = [ 'version' ]
48+ npm . config . set ( 'usage' , false , 'cli' )
49+ }
5750
5851 npm . updateNotification = await updateNotifier ( npm )
5952
0 commit comments