From 7d0cd65b23c0986b631b9b54d87bbe74902cc023 Mon Sep 17 00:00:00 2001 From: Netanel Gilad Date: Tue, 28 Jan 2020 09:41:36 +0200 Subject: [PATCH] access: grant is ok with non-scoped PR-URL: https://github.com/npm/cli/pull/733 Credit: @ Close: #733 Reviewed-by: @Darcy Clarke --- lib/access.js | 2 +- test/tap/access.js | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/access.js b/lib/access.js index 6657f4b0717a1..e850c132eb24b 100644 --- a/lib/access.js +++ b/lib/access.js @@ -112,7 +112,7 @@ access.grant = ([perms, scopeteam, pkg], opts) => { } return modifyPackage(pkg, opts, (pkgName, opts) => { return libaccess.grant(pkgName, scopeteam, perms, opts) - }) + }, false) }) } diff --git a/test/tap/access.js b/test/tap/access.js index 4183c46b538c0..f537db2586409 100644 --- a/test/tap/access.js +++ b/test/tap/access.js @@ -217,6 +217,33 @@ test('npm access grant read-write', function (t) { ) }) +test('npm access grant read-write on unscoped package', function (t) { + server.filteringRequestBody((body) => { + const data = JSON.parse(body) + t.deepEqual(data, { + permissions: 'read-write', + package: 'another' + }, 'got the right body') + return true + }) + server.put('/-/team/myorg/myteam/package', true).reply(201) + common.npm( + [ + 'access', + 'grant', 'read-write', + 'myorg:myteam', + 'another', + '--registry', common.registry + ], + { cwd: pkg }, + function (er, code, stdout, stderr) { + t.ifError(er, 'npm access grant') + t.equal(code, 0, 'exited with Error') + t.end() + } + ) +}) + test('npm access grant others', function (t) { common.npm( [