From 2c12199b3a37ee7aee4fb2570acac441ebcf2ea4 Mon Sep 17 00:00:00 2001 From: zkochan Date: Tue, 24 Jan 2017 01:08:50 +0200 Subject: [PATCH] fix: never preserve symlinks --- src/api/extendOptions.ts | 1 + src/install/linkBins.ts | 4 +++- test/install.ts | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/api/extendOptions.ts b/src/api/extendOptions.ts index 61332ab0b1..de0ed7e8ca 100644 --- a/src/api/extendOptions.ts +++ b/src/api/extendOptions.ts @@ -41,5 +41,6 @@ export default (opts?: PnpmOptions): StrictPnpmOptions => { if (extendedOpts.flatTree === true && !extendedOpts.preserveSymlinks) { throw new Error('`--preserve-symlinks` and so `--flat-tree` are not supported on your system, make sure you are running on Node ≽ 6.3.0') } + extendedOpts.preserveSymlinks = false // TODO: remove preserve-symlinks related code return extendedOpts } diff --git a/src/install/linkBins.ts b/src/install/linkBins.ts index 4b93a5dc03..bb36f21157 100644 --- a/src/install/linkBins.ts +++ b/src/install/linkBins.ts @@ -23,6 +23,8 @@ export default async function linkAllBins (modules: string, binPath: string, pre */ export async function linkPkgBins (target: string, binPath: string, preserveSymlinks: boolean) { const pkg = await safeRequireJson(path.join(target, 'package.json')) + const targetRealPath = await fs.realpath(target) + const extraNodePath = [path.join(targetRealPath, 'node_modules'), path.join(targetRealPath, '..', 'node_modules')] if (!pkg) { logger.warn(`There's a directory in node_modules without package.json: ${target}`) @@ -40,7 +42,7 @@ export async function linkPkgBins (target: string, binPath: string, preserveSyml const targetPath = path.join(target, actualBin) if (!preserveSymlinks) { - const nodePath = getNodePaths(targetPath).join(path.delimiter) + const nodePath = extraNodePath.concat(getNodePaths(targetPath)).join(path.delimiter) return cmdShim(targetPath, externalBinPath, {preserveSymlinks, nodePath}) } diff --git a/test/install.ts b/test/install.ts index 0992d58c6a..93854b3038 100644 --- a/test/install.ts +++ b/test/install.ts @@ -840,7 +840,7 @@ test('shrinkwrap locks npm dependencies', async function (t) { await install(testDefaults({cacheTTL: 0})) - const pkg = project.requireModule('pkg-with-1-dep/node_modules/dep-of-pkg-with-1-dep/package.json') + const pkg = project.requireModule('.resolutions/localhost+4873/pkg-with-1-dep/100.0.0/node_modules/dep-of-pkg-with-1-dep/package.json') t.equal(pkg.version, '100.0.0', 'dependency specified in shrinkwrap.yaml is installed') })