fix: update package on named installation

This commit is contained in:
zkochan
2017-06-11 18:00:22 +03:00
parent 9309aa873e
commit b5c6d4a5fe
2 changed files with 21 additions and 2 deletions

View File

@@ -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,

View File

@@ -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())