MCPcopy Create free account
hub / github.com/nodejs/node / add

Method add

deps/npm/lib/commands/cache.js:164–184  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

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

Callers 1

execMethod · 0.95

Calls 6

usageErrorMethod · 0.80
allMethod · 0.80
mapMethod · 0.65
resumeMethod · 0.65
streamMethod · 0.45
promiseMethod · 0.45

Tested by

no test coverage detected