mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-06 15:07:27 -04:00
fix(independent-leaves): direct deps linking
This commit is contained in:
@@ -145,6 +145,7 @@ export interface ResolvedPackage {
|
||||
optionalDependencies: Set<string>,
|
||||
hasBin: boolean,
|
||||
hasBundledDependencies: boolean,
|
||||
independent: boolean,
|
||||
prepare: boolean,
|
||||
requiresBuild: boolean | undefined, // added to fix issue #1201
|
||||
additionalInfo: {
|
||||
@@ -587,6 +588,9 @@ async function resolveDependency (
|
||||
hasBin,
|
||||
hasBundledDependencies: !!(pkg.bundledDependencies || pkg.bundleDependencies),
|
||||
id: pkgResponse.body.id,
|
||||
independent: (pkg.dependencies === undefined || R.isEmpty(pkg.dependencies)) &&
|
||||
(pkg.optionalDependencies === undefined || R.isEmpty(pkg.optionalDependencies)) &&
|
||||
(pkg.peerDependencies === undefined || R.isEmpty(pkg.peerDependencies)),
|
||||
name: pkg.name,
|
||||
optional: wantedDependency.optional,
|
||||
optionalDependencies: new Set(R.keys(pkg.optionalDependencies)),
|
||||
|
||||
@@ -212,7 +212,7 @@ function resolvePeersOfNode (
|
||||
|
||||
ctx.absolutePathsByNodeId[nodeId] = absolutePath
|
||||
if (!ctx.depGraph[absolutePath] || ctx.depGraph[absolutePath].depth > node.depth) {
|
||||
const independent = ctx.independentLeaves && R.isEmpty(children) && R.isEmpty(node.resolvedPackage.peerDependencies)
|
||||
const independent = ctx.independentLeaves && node.resolvedPackage.independent
|
||||
const centralLocation = node.resolvedPackage.engineCache || path.join(node.resolvedPackage.path, 'node_modules', node.resolvedPackage.name)
|
||||
const peripheralLocation = !independent
|
||||
? path.join(modules, node.resolvedPackage.name)
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import prepare from '@pnpm/prepare'
|
||||
import { addDependenciesToPackage } from 'supi'
|
||||
import isSubdir = require('is-subdir')
|
||||
import path = require('path')
|
||||
import resolveLinkTarget = require('resolve-link-target')
|
||||
import { addDependenciesToPackage, install } from 'supi'
|
||||
import tape = require('tape')
|
||||
import promisifyTape from 'tape-promise'
|
||||
import { testDefaults } from '../utils'
|
||||
@@ -14,6 +17,10 @@ test('install with --independent-leaves', async (t: tape.Test) => {
|
||||
const m = project.requireModule('rimraf')
|
||||
t.ok(typeof m === 'function', 'rimraf() is available')
|
||||
await project.isExecutable('.bin/rimraf')
|
||||
|
||||
await install(await testDefaults({ independentLeaves: true, preferFrozenShrinkwrap: false }))
|
||||
|
||||
t.ok(isSubdir(path.resolve('node_modules'), await resolveLinkTarget(path.resolve('node_modules/rimraf'))), 'non-independent package is not symlinked directly from store')
|
||||
})
|
||||
|
||||
test('--independent-leaves throws exception when executed on node_modules installed w/o the option', async (t: tape.Test) => {
|
||||
|
||||
Reference in New Issue
Block a user