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

Method ls

deps/npm/lib/commands/cache.js:209–230  ·  view source on GitHub ↗
(specs)

Source from the content-addressed store, hash-verified

207
208 // npm cache ls [<spec> ...]
209 async ls (specs) {
210 // This is a derived value
211 const { cache: cachePath } = this.npm.flatOptions
212 const cacheKeys = Object.keys(await cacache.ls(cachePath))
213 if (specs.length > 0) {
214 // get results for each package spec specified
215 const results = new Set()
216 for (const spec of specs) {
217 const parsed = npa(spec)
218 if (parsed.rawSpec !== '' && parsed.type === 'tag') {
219 throw this.usageError('Cannot list cache keys for a tagged package.')
220 }
221 const keySet = await searchCachePackage(cachePath, parsed, cacheKeys)
222 for (const key of keySet) {
223 results.add(key)
224 }
225 }
226 [...results].sort(localeCompare).forEach(key => output.standard(key))
227 return
228 }
229 cacheKeys.sort(localeCompare).forEach(key => output.standard(key))
230 }
231
232 async #npxCache (keys = []) {
233 // This is a derived value

Callers 1

execMethod · 0.95

Calls 6

searchCachePackageFunction · 0.85
usageErrorMethod · 0.80
sortMethod · 0.80
keysMethod · 0.65
addMethod · 0.65
forEachMethod · 0.65

Tested by

no test coverage detected