diff --git a/src/api/install.ts b/src/api/install.ts index 36ed7a3802..29b3a53d23 100644 --- a/src/api/install.ts +++ b/src/api/install.ts @@ -101,9 +101,8 @@ function argsToSpecs (args: string[], defaultTag: string, where: string): Packag return args .map(arg => npa(arg, where)) .map(spec => { - if (spec.type === 'tag' && !spec.raw.endsWith('@latest')) { + if (spec.type === 'tag' && !spec.rawSpec) { spec.fetchSpec = defaultTag - spec.saveSpec = defaultTag } return spec }) diff --git a/test/install/misc.ts b/test/install/misc.ts index ea9f095357..49c274f993 100644 --- a/test/install/misc.ts +++ b/test/install/misc.ts @@ -70,6 +70,16 @@ test('modules without version spec, with custom tag config', async function (t) await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0') }) +test('installing a package by specifying a specific dist-tag', async function (t) { + const project = prepare(t) + + await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', 'beta') + + await installPkgs(['dep-of-pkg-with-1-dep@beta'], testDefaults()) + + await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0') +}) + test('scoped modules with versions (@rstacruz/tap-spec@4.1.1)', async function (t) { const project = prepare(t) await installPkgs(['@rstacruz/tap-spec@4.1.1'], testDefaults())