diff options
Diffstat (limited to 'lib/npm.js')
-rw-r--r-- | lib/npm.js | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/npm.js b/lib/npm.js index fb4fb8d13..74825c97c 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -11,7 +11,6 @@ const usage = require('./utils/npm-usage.js') const which = require('which') const fs = require('@npmcli/fs') -const deref = require('./utils/deref-command.js') const LogFile = require('./utils/log-file.js') const Timers = require('./utils/timers.js') const Display = require('./utils/display.js') @@ -19,6 +18,7 @@ const log = require('./utils/log-shim') const replaceInfo = require('./utils/replace-info.js') const updateNotifier = require('./utils/update-notifier.js') const pkg = require('../package.json') +const cmdList = require('./utils/cmd-list.js') let warnedNonDashArg = false const _load = Symbol('_load') @@ -31,7 +31,6 @@ class Npm extends EventEmitter { command = null updateNotification = null loadErr = null - deref = deref argv = [] #loadPromise = null @@ -61,6 +60,26 @@ class Npm extends EventEmitter { return this.constructor.version } + deref (c) { + if (!c) { + return + } + if (c.match(/[A-Z]/)) { + c = c.replace(/([A-Z])/g, m => '-' + m.toLowerCase()) + } + if (cmdList.plumbing.indexOf(c) !== -1) { + return c + } + // first deref the abbrev, if there is one + // then resolve any aliases + // so `npm install-cl` will resolve to `install-clean` then to `ci` + let a = cmdList.abbrevs[c] + while (cmdList.aliases[a]) { + a = cmdList.aliases[a] + } + return a + } + // Get an instantiated npm command // npm.command is already taken as the currently running command, a refactor // would be needed to change this |