GeezerVison is showing github.com — fix(test): the pinned-Node restart finds the global vp when a local v… · pechhe/t3code@2b8029e
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: scripts/test-landing.test.ts +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -21,6 +21,7 @@ import { | 21 | 21 | planCandidate, | 22 | 22 | plannedRuns, | 23 | 23 | pinnedNodeDecision, | | 24 | + withoutLocalBins, | 24 | 25 | readQuarantine, | 25 | 26 | readWorkspaces, | 26 | 27 | relativeImports, | @@ -1426,6 +1427,11 @@ describe("pinned node", () => { | 1426 | 1427 | ); | 1427 | 1428 | }); | 1428 | 1429 |
| | 1430 | + it("drops project-local bin directories so the restart finds the global vp", () => { | | 1431 | + const path = ["/repo/node_modules/.bin", "/usr/bin", "/repo/apps/web/node_modules/.bin/"]; | | 1432 | + assert.strictEqual(withoutLocalBins(path.join(NodePath.delimiter)), "/usr/bin"); | | 1433 | + }); | | 1434 | + | 1429 | 1435 | it("runs on the Node it already has when that is the pin, or when the invocation only plans", () => { | 1430 | 1436 | assert.deepStrictEqual(pinnedNodeDecision({ pin, running: pin, restarted: false, args: [] }), { | 1431 | 1437 | kind: "run", | |
Collapse file Copy file name to clipboardExpand all lines: scripts/test-landing.ts +13-1Lines changed: 13 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -72,6 +72,14 @@ export function pinnedNodeDecision(input: { | 72 | 72 | }; | 73 | 73 | } | 74 | 74 |
| | 75 | +/** A project-local `vp` has no `env` command, so the restart must find the global one. */ | | 76 | +export function withoutLocalBins(pathValue: string | undefined): string { | | 77 | + return (pathValue ?? "") | | 78 | + .split(NodePath.delimiter) | | 79 | + .filter((entry) => !/[\\/]node_modules[\\/]\.bin[\\/]?$/.test(entry)) | | 80 | + .join(NodePath.delimiter); | | 81 | +} | | 82 | + | 75 | 83 | function runOnPinnedNode(args: ReadonlyArray<string>) { | 76 | 84 | const decision = pinnedNodeDecision({ | 77 | 85 | pin: PINNED_NODE, | @@ -86,7 +94,11 @@ function runOnPinnedNode(args: ReadonlyArray<string>) { | 86 | 94 | } | 87 | 95 | const child = NodeChildProcess.spawnSync(decision.executable, decision.args, { | 88 | 96 | stdio: "inherit", | 89 | | - env: { ...process.env, T3_LANDING_PINNED_NODE: process.versions.node }, | | 97 | + env: { | | 98 | + ...process.env, | | 99 | + PATH: withoutLocalBins(process.env.PATH), | | 100 | + T3_LANDING_PINNED_NODE: process.versions.node, | | 101 | + }, | 90 | 102 | }); | 91 | 103 | // A spawn error means vp is missing; any exit status is the restarted gate's own result, and the | 92 | 104 | // restarted run (or vp, when it cannot provide the runtime) has already said why it failed. | |
|