@@ -11,14 +11,14 @@ const usage = require('./utils/npm-usage.js')
11
11
const which = require ( 'which' )
12
12
const fs = require ( '@npmcli/fs' )
13
13
14
- const deref = require ( './utils/deref-command.js' )
15
14
const LogFile = require ( './utils/log-file.js' )
16
15
const Timers = require ( './utils/timers.js' )
17
16
const Display = require ( './utils/display.js' )
18
17
const log = require ( './utils/log-shim' )
19
18
const replaceInfo = require ( './utils/replace-info.js' )
20
19
const updateNotifier = require ( './utils/update-notifier.js' )
21
20
const pkg = require ( '../package.json' )
21
+ const cmdList = require ( './utils/cmd-list.js' )
22
22
23
23
let warnedNonDashArg = false
24
24
const _load = Symbol ( '_load' )
@@ -31,7 +31,6 @@ class Npm extends EventEmitter {
31
31
command = null
32
32
updateNotification = null
33
33
loadErr = null
34
- deref = deref
35
34
argv = [ ]
36
35
37
36
#loadPromise = null
@@ -61,6 +60,26 @@ class Npm extends EventEmitter {
61
60
return this . constructor . version
62
61
}
63
62
63
+ deref ( c ) {
64
+ if ( ! c ) {
65
+ return
66
+ }
67
+ if ( c . match ( / [ A - Z ] / ) ) {
68
+ c = c . replace ( / ( [ A - Z ] ) / g, m => '-' + m . toLowerCase ( ) )
69
+ }
70
+ if ( cmdList . plumbing . indexOf ( c ) !== - 1 ) {
71
+ return c
72
+ }
73
+ // first deref the abbrev, if there is one
74
+ // then resolve any aliases
75
+ // so `npm install-cl` will resolve to `install-clean` then to `ci`
76
+ let a = cmdList . abbrevs [ c ]
77
+ while ( cmdList . aliases [ a ] ) {
78
+ a = cmdList . aliases [ a ]
79
+ }
80
+ return a
81
+ }
82
+
64
83
// Get an instantiated npm command
65
84
// npm.command is already taken as the currently running command, a refactor
66
85
// would be needed to change this
0 commit comments