From 99a60c0a66322f57e5cee8ceaff3dd87f977ddc8 Mon Sep 17 00:00:00 2001 From: Affaan Mustafa Date: Sun, 12 Apr 2026 22:19:16 -0700 Subject: [PATCH] fix: make npm pack test shell-safe on windows --- tests/scripts/build-opencode.test.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/scripts/build-opencode.test.js b/tests/scripts/build-opencode.test.js index 3cd62c19..253d16e7 100644 --- a/tests/scripts/build-opencode.test.js +++ b/tests/scripts/build-opencode.test.js @@ -26,12 +26,11 @@ function main() { let failed = 0 const repoRoot = path.join(__dirname, "..", "..") -const packageJson = JSON.parse( - fs.readFileSync(path.join(repoRoot, "package.json"), "utf8") -) -const buildScript = path.join(repoRoot, "scripts", "build-opencode.js") -const distEntry = path.join(repoRoot, ".opencode", "dist", "index.js") -const npmExecutable = process.platform === "win32" ? "npm.cmd" : "npm" + const packageJson = JSON.parse( + fs.readFileSync(path.join(repoRoot, "package.json"), "utf8") + ) + const buildScript = path.join(repoRoot, "scripts", "build-opencode.js") + const distEntry = path.join(repoRoot, ".opencode", "dist", "index.js") const tests = [ ["package.json exposes the OpenCode build and prepack hooks", () => { assert.strictEqual(packageJson.scripts["build:opencode"], "node scripts/build-opencode.js") @@ -47,11 +46,12 @@ const npmExecutable = process.platform === "win32" ? "npm.cmd" : "npm" assert.ok(fs.existsSync(distEntry), ".opencode/dist/index.js should exist after build") }], ["npm pack includes the compiled OpenCode dist payload", () => { - const result = spawnSync(npmExecutable, ["pack", "--dry-run", "--json"], { + const result = spawnSync("npm", ["pack", "--dry-run", "--json"], { cwd: repoRoot, encoding: "utf8", + shell: process.platform === "win32", }) - assert.strictEqual(result.status, 0, result.stderr) + assert.strictEqual(result.status, 0, result.error?.message || result.stderr) const packOutput = JSON.parse(result.stdout) const packagedPaths = new Set(packOutput[0]?.files?.map((file) => file.path) ?? [])