From ac30f8913dfbf7252b0ea227496ce7565b7ee4f5 Mon Sep 17 00:00:00 2001 From: Matysh Date: Fri, 14 Aug 2026 12:15:06 +0300 Subject: [PATCH] fix: build the gate CLI path with fileURLToPath, not URL.pathname MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Windows URL.pathname yields /C:/..., which spawnSync then reads as C:\C:\... and the whole npm test run dies in this one test. Linux CI never caught it because both spellings coincide there — which is exactly why the canonical gate lives on Linux and the local run is advisory. Issue: #133 User-Visible: no --- test/process-gate.test.mjs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/process-gate.test.mjs b/test/process-gate.test.mjs index b4a74911..459361a5 100644 --- a/test/process-gate.test.mjs +++ b/test/process-gate.test.mjs @@ -4,6 +4,7 @@ import { spawnSync } from 'node:child_process'; import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; +import { fileURLToPath } from 'node:url'; import { ALLOWED_STATUS, @@ -270,7 +271,10 @@ test('the CLI exits 0 on a clean range and 1 on a broken one', (t) => { return; } const dir = mkdtempSync(join(tmpdir(), 'hp-gate-')); - const gate = new URL('../scripts/process-gate.mjs', import.meta.url).pathname; + // fileURLToPath, а не URL.pathname: на Windows pathname даёт «/C:/…», и + // spawnSync прочитал бы его как «C:\C:\…» (#133). Linux CI это не ловил — + // оба варианта там совпадают. + const gate = fileURLToPath(new URL('../scripts/process-gate.mjs', import.meta.url)); const git = (...args) => { const r = spawnSync('git', ['-C', dir, ...args], { encoding: 'utf8' }); assert.equal(r.status, 0, `git ${args.join(' ')}: ${r.stderr}`);