MCPcopy Create free account
hub / github.com/npm/cli / #getPackage

Method #getPackage

lib/commands/access.js:180–201  ·  view source on GitHub ↗
(name, requireScope)

Source from the content-addressed store, hash-verified

178 }
179
180 async #getPackage (name, requireScope) {
181 if (!name) {
182 try {
183 const { content } = await pkgJson.normalize(this.npm.prefix)
184 name = content.name
185 } catch (err) {
186 if (err.code === 'ENOENT') {
187 throw Object.assign(new Error('no package name given and no package.json found'), {
188 code: 'ENOENT',
189 })
190 } else {
191 throw err
192 }
193 }
194 }
195
196 const spec = npa(name)
197 if (requireScope && !spec.scope) {
198 throw this.usageError('This command is only available for scoped packages.')
199 }
200 return name
201 }
202
203 #output (items, limiter) {
204 const outputs = {}

Callers 4

#listCollaboratorsMethod · 0.95
#getStatusMethod · 0.95
#setMfaMethod · 0.95
#setStatusMethod · 0.95

Calls 1

usageErrorMethod · 0.80

Tested by

no test coverage detected