From ccb8ae1d18a3fa66caabd61c6a9885eedb62558a Mon Sep 17 00:00:00 2001 From: Lex Christopherson Date: Fri, 27 Feb 2026 10:00:26 -0600 Subject: [PATCH] fix(ci): cross-platform test runner for Windows glob expansion npm scripts pass `tests/*.test.cjs` to node/c8 as a literal string on Windows (PowerShell/cmd don't expand globs). Adding `shell: bash` to CI steps doesn't help because c8 spawns node as a child process using the system shell. Use a Node script to enumerate test files cross-platform. Co-Authored-By: Claude Opus 4.6 --- package.json | 4 ++-- scripts/run-tests.cjs | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 scripts/run-tests.cjs diff --git a/package.json b/package.json index a23f9f450..7c571acdd 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "scripts": { "build:hooks": "node scripts/build-hooks.js", "prepublishOnly": "npm run build:hooks", - "test": "node --test tests/*.test.cjs", - "test:coverage": "c8 --check-coverage --lines 70 --reporter text --include 'get-shit-done/bin/lib/*.cjs' --exclude 'tests/**' --all node --test tests/*.test.cjs" + "test": "node scripts/run-tests.cjs", + "test:coverage": "c8 --check-coverage --lines 70 --reporter text --include 'get-shit-done/bin/lib/*.cjs' --exclude 'tests/**' --all node scripts/run-tests.cjs" } } diff --git a/scripts/run-tests.cjs b/scripts/run-tests.cjs new file mode 100644 index 000000000..a771e2a30 --- /dev/null +++ b/scripts/run-tests.cjs @@ -0,0 +1,25 @@ +#!/usr/bin/env node +// Cross-platform test runner — resolves test file globs via Node +// instead of relying on shell expansion (which fails on Windows PowerShell/cmd). +'use strict'; + +const { readdirSync } = require('fs'); +const { join } = require('path'); +const { execFileSync } = require('child_process'); + +const testDir = join(__dirname, '..', 'tests'); +const files = readdirSync(testDir) + .filter(f => f.endsWith('.test.cjs')) + .sort() + .map(f => join('tests', f)); + +if (files.length === 0) { + console.error('No test files found in tests/'); + process.exit(1); +} + +try { + execFileSync(process.execPath, ['--test', ...files], { stdio: 'inherit' }); +} catch (err) { + process.exit(err.status || 1); +}