Skip to content

Commit d5da01e

Browse files
committed
fix: add glob package, use cross-platform test runner
1 parent abe5190 commit d5da01e

3 files changed

Lines changed: 110 additions & 1 deletion

File tree

package-lock.json

Lines changed: 95 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"format:check": "prettier --check 'src/**/*.{ts,tsx}'",
3333
"check": "npm run typecheck && npm run lint && npm run format:check",
3434
"build": "npm run check && npm run bundle && node -e \"require('fs').chmodSync('dist/cli.js', 0o755)\"",
35-
"test": "node --import tsx --test src/tests/*.test.ts",
35+
"test": "node src/tests/run-tests.mjs",
3636
"test:single": "tsx --test",
3737
"prepack": "npm run build",
3838
"prepare": "husky"
@@ -58,6 +58,7 @@
5858
"eslint": "^9.39.4",
5959
"eslint-config-prettier": "^10.1.8",
6060
"eslint-plugin-react-hooks": "^7.1.1",
61+
"glob": "^13.0.6",
6162
"husky": "^9.1.7",
6263
"lint-staged": "^17.0.4",
6364
"prettier": "^3.8.3",

src/tests/run-tests.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Cross-platform test runner: finds all *.test.ts files and runs them via tsx.
2+
// Uses the glob package for reliable cross-platform pattern expansion (Node 20+).
3+
/* eslint-disable */
4+
5+
import { globSync } from "glob";
6+
import { spawnSync } from "child_process";
7+
8+
const cwd = new URL("../..", import.meta.url);
9+
const testFiles = globSync("src/tests/*.test.ts", { cwd });
10+
11+
const result = spawnSync(process.execPath, ["--import", "tsx", "--test", ...testFiles], { stdio: "inherit", cwd });
12+
13+
process.exit(result.status ?? 1);

0 commit comments

Comments
 (0)