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

Method exec

deps/npm/lib/commands/access.js:73–116  ·  view source on GitHub ↗
([cmd, subcmd, ...args])

Source from the content-addressed store, hash-verified

71 }
72
73 async exec ([cmd, subcmd, ...args]) {
74 if (!cmd) {
75 throw this.usageError()
76 }
77 if (!commands.includes(cmd)) {
78 throw this.usageError(`${cmd} is not a valid access command`)
79 }
80 // All commands take at least one more parameter so we can do this check up front
81 if (!subcmd) {
82 throw this.usageError()
83 }
84
85 switch (cmd) {
86 case 'grant':
87 if (!['read-only', 'read-write'].includes(subcmd)) {
88 throw this.usageError('grant must be either `read-only` or `read-write`')
89 }
90 if (!args[0]) {
91 throw this.usageError('`<scope:team>` argument is required')
92 }
93 return this.#grant(subcmd, args[0], args[1])
94 case 'revoke':
95 return this.#revoke(subcmd, args[0])
96 case 'list':
97 case 'ls':
98 if (subcmd === 'packages') {
99 return this.#listPackages(args[0], args[1])
100 }
101 if (subcmd === 'collaborators') {
102 return this.#listCollaborators(args[0], args[1])
103 }
104 throw this.usageError(`list ${subcmd} is not a valid access command`)
105 case 'get':
106 if (subcmd !== 'status') {
107 throw this.usageError(`get ${subcmd} is not a valid access command`)
108 }
109 return this.#getStatus(args[0])
110 case 'set':
111 if (!setCommands.includes(subcmd)) {
112 throw this.usageError(`set ${subcmd} is not a valid access command`)
113 }
114 return this.#set(subcmd, args[0])
115 }
116 }
117
118 async #grant (permissions, scope, pkg) {
119 await otplease(this.npm, this.npm.flatOptions, async (opts) => {

Callers

nothing calls this directly

Calls 8

#grantMethod · 0.95
#revokeMethod · 0.95
#listPackagesMethod · 0.95
#listCollaboratorsMethod · 0.95
#getStatusMethod · 0.95
#setMethod · 0.95
usageErrorMethod · 0.80
includesMethod · 0.80

Tested by

no test coverage detected