From 8e6196b407fb232f11eea89253efc32ec4d3cebc Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Wed, 4 Jul 2018 00:37:24 +0300 Subject: [PATCH] fix(recursive): resolve directory deps correctly inside monorepo ref #1253 --- packages/pnpm/test/recursive.ts | 27 +++++++++++++++++++++++++++ packages/supi/src/api/install.ts | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/pnpm/test/recursive.ts b/packages/pnpm/test/recursive.ts index 0b822f84dc..c9d2560105 100644 --- a/packages/pnpm/test/recursive.ts +++ b/packages/pnpm/test/recursive.ts @@ -54,6 +54,33 @@ test('recursive install/uninstall', async (t: tape.Test) => { await projects['project-2'].hasNot('is-negative') }) +// Created to cover the issue described in https://github.com/pnpm/pnpm/issues/1253 +test('recursive install with package that has link', async (t: tape.Test) => { + const projects = preparePackages(t, [ + { + name: 'project-1', + version: '1.0.0', + dependencies: { + 'is-positive': '1.0.0', + 'project-2': 'link:../project-2', + }, + }, + { + name: 'project-2', + version: '1.0.0', + dependencies: { + 'is-negative': '1.0.0', + }, + }, + ]) + + await execPnpm('recursive', 'install') + + t.ok(projects['project-1'].requireModule('is-positive')) + t.ok(projects['project-1'].requireModule('project-2/package.json')) + t.ok(projects['project-2'].requireModule('is-negative')) +}) + test('recursive update', async (t: tape.Test) => { const projects = preparePackages(t, [ { diff --git a/packages/supi/src/api/install.ts b/packages/supi/src/api/install.ts index d0cd8cca75..5d7cd2c99c 100644 --- a/packages/supi/src/api/install.ts +++ b/packages/supi/src/api/install.ts @@ -727,7 +727,7 @@ async function installInContext ( linkToBin: opts.bin, skipInstall: true, } - const externalPkgs = installCtx.localPackages.map((localPackage) => localPackage.resolution.directory) + const externalPkgs = installCtx.localPackages.map((localPackage) => path.join(opts.prefix, localPackage.resolution.directory)) await externalLink(externalPkgs, installCtx.nodeModules, linkOpts) } }