MCPcopy Index your code
hub / github.com/nodejs/node / deref

Function deref

deps/npm/lib/utils/cmd-list.js:147–176  ·  view source on GitHub ↗
(c)

Source from the content-addressed store, hash-verified

145}
146
147const deref = (c) => {
148 if (!c) {
149 return
150 }
151
152 // Translate camelCase to snake-case (i.e. installTest to install-test)
153 if (c.match(/[A-Z]/)) {
154 c = c.replace(/([A-Z])/g, m => '-' + m.toLowerCase())
155 }
156
157 // if they asked for something exactly we are done
158 if (commands.includes(c)) {
159 return c
160 }
161
162 // if they asked for a direct alias
163 if (aliases[c]) {
164 return aliases[c]
165 }
166
167 const abbrevs = abbrev(commands.concat(Object.keys(aliases)))
168
169 // first deref the abbrev,
170 // if there is one then resolve any aliases so `npm install-cl` will resolve to `install-clean` then to `ci`
171 let a = abbrevs[c]
172 while (aliases[a]) {
173 a = aliases[a]
174 }
175 return a
176}
177
178module.exports = {
179 aliases,

Callers 4

cmdMethod · 0.85
#loadMethod · 0.85
cmdComplFunction · 0.85
execMethod · 0.85

Calls 4

includesMethod · 0.80
concatMethod · 0.80
matchMethod · 0.65
keysMethod · 0.65

Tested by

no test coverage detected