From ff099414faabc12e60b2e3542aabc9b8871a91c3 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Fri, 8 Nov 2019 01:36:07 +0200 Subject: [PATCH] fix: recursive update should modify the manifests ref #2133 --- packages/pnpm/src/cmd/recursive/index.ts | 5 +- packages/pnpm/test/update.ts | 67 +++++++++++++++++++++++- 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/packages/pnpm/src/cmd/recursive/index.ts b/packages/pnpm/src/cmd/recursive/index.ts index 43ae342f3f..d4e3daa8fd 100644 --- a/packages/pnpm/src/cmd/recursive/index.ts +++ b/packages/pnpm/src/cmd/recursive/index.ts @@ -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++ diff --git a/packages/pnpm/test/update.ts b/packages/pnpm/test/update.ts index 0588369719..87d559778d 100644 --- a/packages/pnpm/test/update.ts +++ b/packages/pnpm/test/update.ts @@ -13,7 +13,7 @@ import { const test = promisifyTape(tape) const testOnly = promisifyTape(tape.only) -test('update', async function (t: tape.Test) { +test('update ', 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('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)