Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/commands/access.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ class Access extends BaseCommand {
}

async #grant (permissions, scope, pkg) {
await libnpmaccess.setPermissions(scope, pkg, permissions)
await libnpmaccess.setPermissions(scope, pkg, permissions, this.npm.flatOptions)
}

async #revoke (scope, pkg) {
await libnpmaccess.removePermissions(scope, pkg)
await libnpmaccess.removePermissions(scope, pkg, this.npm.flatOptions)
}

async #listPackages (owner, pkg) {
Expand Down
16 changes: 14 additions & 2 deletions test/lib/commands/access.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,16 @@ t.test('grant', t => {
})

t.test('read-only', async t => {
const { npm } = await loadMockNpm(t)
const authToken = 'abcd1234'
const { npm } = await loadMockNpm(t, {
config: {
'//registry.npmjs.org/:_authToken': authToken,
},
})
const registry = new MockRegistry({
tap: t,
registry: npm.config.get('registry'),
authorization: authToken,
})
const permissions = 'read-only'
registry.setPermissions({ spec: '@npmcli/test-package', team: '@npm:test-team', permissions })
Expand All @@ -84,10 +90,16 @@ t.test('grant', t => {

t.test('revoke', t => {
t.test('success', async t => {
const { npm } = await loadMockNpm(t)
const authToken = 'abcd1234'
const { npm } = await loadMockNpm(t, {
config: {
'//registry.npmjs.org/:_authToken': authToken,
},
})
const registry = new MockRegistry({
tap: t,
registry: npm.config.get('registry'),
authorization: authToken,
})
registry.removePermissions({ spec: '@npmcli/test-package', team: '@npm:test-team' })
await npm.exec('access', ['revoke', '@npm:test-team', '@npmcli/test-package'])
Expand Down