fix: never preserve symlinks

This commit is contained in:
zkochan
2017-01-24 01:08:50 +02:00
committed by Zoltan Kochan
parent 79d019ff4f
commit 2c12199b3a
3 changed files with 5 additions and 2 deletions

View File

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

View File

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

View File

@@ -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')
})