fix: recursive update should modify the manifests

ref #2133
This commit is contained in:
Zoltan Kochan
2019-11-08 01:36:07 +02:00
parent c1cb2d1829
commit ff099414fa
2 changed files with 68 additions and 4 deletions

View File

@@ -309,8 +309,7 @@ export async function recursive (
if (opts.save !== false) {
await Promise.all(
mutatedPkgs
.filter((mutatedPkg, index) => mutatedImporters[index].mutation !== 'install')
.map(({ manifest, rootDir }, index) => writeImporterManifests[index](manifest))
.map(({ manifest }, index) => writeImporterManifests[index](manifest))
)
}
return true
@@ -383,7 +382,7 @@ export async function recursive (
storeController,
},
)
if (action !== install && opts.save !== false) {
if (opts.save !== false) {
await writeImporterManifest(newManifest)
}
result.passes++

View File

@@ -13,7 +13,7 @@ import {
const test = promisifyTape(tape)
const testOnly = promisifyTape(tape.only)
test('update', async function (t: tape.Test) {
test('update <dep>', async function (t: tape.Test) {
const project = prepare(t)
await addDistTag('dep-of-pkg-with-1-dep', '101.0.0', 'latest')
@@ -50,6 +50,23 @@ test('update --no-save', async function (t: tape.Test) {
t.equal(pkg.dependencies?.['foo'], '^100.0.0')
})
test('update', async function (t: tape.Test) {
await addDistTag('foo', '100.1.0', 'latest')
const project = prepare(t, {
dependencies: {
foo: '^100.0.0',
},
})
await execPnpm('update')
const lockfile = await project.readLockfile()
t.ok(lockfile.packages['/foo/100.1.0'])
const pkg = await readPackage(process.cwd())
t.equal(pkg.dependencies?.['foo'], '^100.1.0')
})
test('recursive update --no-save', async function (t: tape.Test) {
await addDistTag('foo', '100.1.0', 'latest')
const projects = preparePackages(t, [
@@ -73,6 +90,54 @@ test('recursive update --no-save', async function (t: tape.Test) {
t.equal(pkg.dependencies?.['foo'], '^100.0.0')
})
test('recursive update', async function (t: tape.Test) {
await addDistTag('foo', '100.1.0', 'latest')
const projects = preparePackages(t, [
{
location: 'project',
package: {
dependencies: {
foo: '^100.0.0',
},
},
},
])
await writeYamlFile('pnpm-workspace.yaml', { packages: ['**', '!store/**'] })
await execPnpm('recursive', 'update')
const lockfile = await readYamlFile<any>('pnpm-lock.yaml') // tslint:disable-line
t.ok(lockfile.packages['/foo/100.1.0'])
const pkg = await readPackage(path.resolve('project'))
t.equal(pkg.dependencies?.['foo'], '^100.1.0')
})
test('recursive update --no-shared-workspace-lockfile', async function (t: tape.Test) {
await addDistTag('foo', '100.1.0', 'latest')
const projects = preparePackages(t, [
{
location: 'project',
package: {
name: 'project',
dependencies: {
foo: '^100.0.0',
},
},
},
])
await writeYamlFile('pnpm-workspace.yaml', { packages: ['**', '!store/**'] })
await execPnpm('recursive', 'update', '--no-shared-workspace-lockfile')
const lockfile = await projects['project'].readLockfile()
t.ok(lockfile.packages['/foo/100.1.0'])
const pkg = await readPackage(path.resolve('project'))
t.equal(pkg.dependencies?.['foo'], '^100.1.0')
})
test('update should not install the dependency if it is not present already', async function (t: tape.Test) {
const project = prepare(t)