diff --git a/lib/dist-tag.js b/lib/dist-tag.js index 176e61221eef0..64bb97b61a4c6 100644 --- a/lib/dist-tag.js +++ b/lib/dist-tag.js @@ -119,7 +119,8 @@ function remove (spec, tag, opts) { delete tags[tag] const url = `/-/package/${spec.escapedName}/dist-tags/${encodeURIComponent(tag)}` const reqOpts = opts.concat({ - method: 'DELETE' + method: 'DELETE', + spec }) return otplease(reqOpts, reqOpts => regFetch(url, reqOpts)).then(() => { output(`-${tag}: ${spec.name}@${version}`) diff --git a/test/tap/dist-tag.js b/test/tap/dist-tag.js index 0567964d35a23..a5cce5d2a0f93 100644 --- a/test/tap/dist-tag.js +++ b/test/tap/dist-tag.js @@ -46,6 +46,12 @@ function mocks (server) { server.delete('/-/package/@scoped%2fanother/dist-tags/c') .reply(200, { c: '7.7.7' }) + // using a scoped registry + server.get('/-/package/@scoped%2ffoo/dist-tags') + .reply(200, { latest: '2.0.0', a: '0.0.2', b: '0.6.0' }) + server.delete('/-/package/@scoped%2ffoo/dist-tags/b') + .reply(200, { b: '0.6.0' }) + // rm server.get('/-/package/@scoped%2fanother/dist-tags') .reply(200, { latest: '4.0.0' }) @@ -232,6 +238,31 @@ test('npm dist-tags rm @scoped/another nonexistent', function (t) { ) }) +test('npm dist-tags rm with registry assigned to scope', function (t) { + fs.writeFileSync(path.resolve(pkg, '.npmrc'), ` +@scoped:registry=${common.registry} +${common.registry.replace(/^https?:/, '')}:_authToken=taken +`) + + common.npm( + [ + 'dist-tags', + 'rm', '@scoped/foo', 'b', + '--loglevel', 'silent', + '--userconfig', path.resolve(pkg, '.npmrc') + ], + { cwd: pkg }, + function (er, code, stdout, stderr) { + t.ifError(er, 'npm access') + t.notOk(code, 'exited OK') + t.notOk(stderr, 'no error output') + t.equal(stdout, '-b: @scoped/foo@0.6.0\n') + + t.end() + } + ) +}) + test('cleanup', function (t) { t.pass('cleaned up') rimraf.sync(pkg)