Skip to content

Commit fc46489

Browse files
wraithgarfritzy
authored andcommittedMar 2, 2023
fix(access): only complete once
1 parent b43961a commit fc46489

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed
 

‎lib/commands/access.js

+16-14
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,22 @@ class Access extends BaseCommand {
5353
return commands
5454
}
5555

56-
switch (argv[2]) {
57-
case 'grant':
58-
return ['read-only', 'read-write']
59-
case 'revoke':
60-
return []
61-
case 'list':
62-
case 'ls':
63-
return ['packages', 'collaborators']
64-
case 'get':
65-
return ['status']
66-
case 'set':
67-
return setCommands
68-
default:
69-
throw new Error(argv[2] + ' not recognized')
56+
if (argv.length === 3) {
57+
switch (argv[2]) {
58+
case 'grant':
59+
return ['read-only', 'read-write']
60+
case 'revoke':
61+
return []
62+
case 'list':
63+
case 'ls':
64+
return ['packages', 'collaborators']
65+
case 'get':
66+
return ['status']
67+
case 'set':
68+
return setCommands
69+
default:
70+
throw new Error(argv[2] + ' not recognized')
71+
}
7072
}
7173
}
7274

‎test/lib/commands/access.js

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ t.test('completion', async t => {
3030
])
3131
testComp(['npm', 'access', 'grant'], ['read-only', 'read-write'])
3232
testComp(['npm', 'access', 'revoke'], [])
33+
testComp(['npm', 'access', 'grant', ''], [])
3334

3435
await t.rejects(
3536
access.completion({ conf: { argv: { remain: ['npm', 'access', 'foobar'] } } }),

0 commit comments

Comments
 (0)
Please sign in to comment.