| 162 | // npm cache add <tarball>... |
| 163 | // npm cache add <folder>... |
| 164 | async add (args) { |
| 165 | log.silly('cache add', 'args', args) |
| 166 | if (args.length === 0) { |
| 167 | throw this.usageError('First argument to `add` is required') |
| 168 | } |
| 169 | |
| 170 | await Promise.all(args.map(async spec => { |
| 171 | log.silly('cache add', 'spec', spec) |
| 172 | // we ask pacote for the thing, and then just throw the data away so that it tee-pipes it into the cache like it does for a normal request. |
| 173 | await pacote.tarball.stream(spec, stream => { |
| 174 | stream.resume() |
| 175 | return stream.promise() |
| 176 | }, { ...this.npm.flatOptions, _isRoot: true }) |
| 177 | |
| 178 | await pacote.manifest(spec, { |
| 179 | ...this.npm.flatOptions, |
| 180 | fullMetadata: true, |
| 181 | _isRoot: true, |
| 182 | }) |
| 183 | })) |
| 184 | } |
| 185 | |
| 186 | async verify () { |
| 187 | // this is a derived value |