fix: avoid circular symlink with hoist-workspace-packages (#7495)

This commit is contained in:
Zoltan Kochan
2024-01-06 13:20:58 +01:00
committed by GitHub
parent c0182b429f
commit ff10acadec
4 changed files with 11 additions and 2 deletions

View File

@@ -0,0 +1,7 @@
---
"@pnpm/headless": patch
"@pnpm/core": patch
"pnpm": patch
---
When `hoisted-workspace-packages` is `true` don't hoist the root package even if it has a name. Otherwise we would create a circular symlink.

View File

@@ -228,7 +228,7 @@ export async function linkPackages (
virtualStoreDir: opts.virtualStoreDir,
hoistedWorkspacePackages: opts.hoistWorkspacePackages
? projects.reduce((hoistedWorkspacePackages, project) => {
if (project.manifest.name) {
if (project.manifest.name && project.id !== '.') {
hoistedWorkspacePackages[project.id] = {
dir: project.rootDir,
name: project.manifest.name,

View File

@@ -903,6 +903,7 @@ test('hoistWorkspacePackages should hoist all workspace projects', async () => {
await projects['root'].has('.pnpm/node_modules/@pnpm.e2e/bar')
await projects['root'].has('.pnpm/node_modules/package')
await projects['root'].has('.pnpm/node_modules/package2')
await projects['root'].hasNot('.pnpm/node_modules/root')
await projects['root'].hasNot('@pnpm.e2e/foobar')
await projects['root'].hasNot('@pnpm.e2e/foo')
await projects['root'].hasNot('@pnpm.e2e/bar')
@@ -921,4 +922,5 @@ test('hoistWorkspacePackages should hoist all workspace projects', async () => {
}))
await projects['root'].has('.pnpm/node_modules/package')
await projects['root'].has('.pnpm/node_modules/package2')
await projects['root'].hasNot('.pnpm/node_modules/root')
})

View File

@@ -427,7 +427,7 @@ export async function headlessInstall (opts: HeadlessOptions): Promise<Installat
virtualStoreDir,
hoistedWorkspacePackages: opts.hoistWorkspacePackages
? Object.values(opts.allProjects).reduce((hoistedWorkspacePackages, project) => {
if (project.manifest.name) {
if (project.manifest.name && project.id !== '.') {
hoistedWorkspacePackages[project.id] = {
dir: project.rootDir,
name: project.manifest.name,