From 3322212f145cf31093afebcddc6bb48e7a44a9c7 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 1 Jun 2026 09:17:36 +0200 Subject: [PATCH] fix(ci): tolerate pnpm workspace state on Windows hydrate --- .github/workflows/crabbox-hydrate.yml | 11 ++++++++++- test/scripts/package-acceptance-workflow.test.ts | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/crabbox-hydrate.yml b/.github/workflows/crabbox-hydrate.yml index 29f0a6f727ea..bc03e8b41153 100644 --- a/.github/workflows/crabbox-hydrate.yml +++ b/.github/workflows/crabbox-hydrate.yml @@ -435,7 +435,16 @@ jobs: if (Test-Path $workspaceNodeModules) { $workspaceNodeModulesItem = Get-Item $workspaceNodeModules -Force if (($workspaceNodeModulesItem.Attributes -band [System.IO.FileAttributes]::ReparsePoint) -eq 0) { - throw "workspace node_modules exists and is not a link: $workspaceNodeModules" + $nodeModulesChildren = @(Get-ChildItem -LiteralPath $workspaceNodeModules -Force) + $hasOnlyPnpmWorkspaceState = $nodeModulesChildren.Count -eq 1 -and $nodeModulesChildren[0].Name -eq ".pnpm-workspace-state-v1.json" + if ($nodeModulesChildren.Count -ne 0 -and -not $hasOnlyPnpmWorkspaceState) { + throw "workspace node_modules exists and is not a link: $workspaceNodeModules" + } + foreach ($nodeModulesChild in $nodeModulesChildren) { + Remove-Item -LiteralPath $nodeModulesChild.FullName -Force + } + Remove-Item -LiteralPath $workspaceNodeModules -Force + New-Item -ItemType Junction -Path $workspaceNodeModules -Target $env:PNPM_CONFIG_MODULES_DIR | Out-Null } } else { New-Item -ItemType Junction -Path $workspaceNodeModules -Target $env:PNPM_CONFIG_MODULES_DIR | Out-Null diff --git a/test/scripts/package-acceptance-workflow.test.ts b/test/scripts/package-acceptance-workflow.test.ts index 25b49d5c92f7..8fd612afc095 100644 --- a/test/scripts/package-acceptance-workflow.test.ts +++ b/test/scripts/package-acceptance-workflow.test.ts @@ -181,6 +181,7 @@ describe("package acceptance workflow", () => { expect(hydrateWindowsPnpm.run).toContain( 'New-Item -ItemType Junction -Path $workspaceNodeModules -Target $env:PNPM_CONFIG_MODULES_DIR', ); + expect(hydrateWindowsPnpm.run).toContain(".pnpm-workspace-state-v1.json"); expect(hydrateWindowsPnpm.run).not.toContain("Remove-Item -Recurse -Force"); expect(hydrateWindowsPnpm.run).not.toContain("Add-Content -Path $env:GITHUB_ENV"); expect(hydrateWindowsPnpm.run).not.toContain("Add-Content -Path $env:GITHUB_PATH");