MCPcopy Create free account
hub / github.com/npm/cli / add

Method add

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 3

execMethod · 0.95
searchCachePackageFunction · 0.45
lsMethod · 0.45

Calls 3

usageErrorMethod · 0.80
resumeMethod · 0.80
manifestMethod · 0.80

Tested by

no test coverage detected