From b5c6d4a5fed4f391663c123e86a2f703ac4571fa Mon Sep 17 00:00:00 2001 From: zkochan Date: Sun, 11 Jun 2017 18:00:22 +0300 Subject: [PATCH] fix: update package on named installation --- src/api/install.ts | 5 +++-- test/install/misc.ts | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/api/install.ts b/src/api/install.ts index d156df5fbe..7f725d47e7 100644 --- a/src/api/install.ts +++ b/src/api/install.ts @@ -218,13 +218,14 @@ async function installInContext ( const oldSpecs = parts[0] const newSpecs = parts[1] + const update = opts.update || installType === 'named' const installOpts = { root: ctx.root, storePath: ctx.storePath, localRegistry: opts.localRegistry, registry: ctx.shrinkwrap.registry, force: opts.force, - depth: opts.update ? opts.depth : + depth: update ? opts.depth : (R.equals(ctx.shrinkwrap.packages, ctx.privateShrinkwrap.packages) ? opts.repeatInstallDepth : Infinity), engineStrict: opts.engineStrict, nodeVersion: opts.nodeVersion, @@ -238,7 +239,7 @@ async function installInContext ( offline: opts.offline, rawNpmConfig: opts.rawNpmConfig, nodeModules: nodeModulesPath, - update: opts.update, + update, keypath: [], referencedFrom: opts.prefix, prefix: opts.prefix, diff --git a/test/install/misc.ts b/test/install/misc.ts index 40c4c0a15f..45789be99c 100644 --- a/test/install/misc.ts +++ b/test/install/misc.ts @@ -76,6 +76,7 @@ test('modules without version spec, with custom tag config', async function (t) const tag = 'beta' + await addDistTag('dep-of-pkg-with-1-dep', '100.1.0', 'latest') await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', tag) await installPkgs(['dep-of-pkg-with-1-dep'], testDefaults({tag})) @@ -86,6 +87,7 @@ test('modules without version spec, with custom tag config', async function (t) 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.1.0', 'latest') await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', 'beta') await installPkgs(['dep-of-pkg-with-1-dep@beta'], testDefaults()) @@ -93,6 +95,22 @@ test('installing a package by specifying a specific dist-tag', async function (t await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0') }) +test('update a package when installing with a dist-tag', async function (t: tape.Test) { + const project = prepare(t) + + await addDistTag('dep-of-pkg-with-1-dep', '100.1.0', 'latest') + await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', 'beta') + + await installPkgs(['dep-of-pkg-with-1-dep'], testDefaults({saveDev: true})) + + await installPkgs(['dep-of-pkg-with-1-dep@beta'], testDefaults({saveDev: true})) + + await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0') + + const pkg = await readPkg() + t.equal(pkg.devDependencies['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())