(specs)
| 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 |
no test coverage detected