fix: make root test use pnpm package filtering

This commit is contained in:
2026-03-28 16:58:00 +08:00
parent 6aea5a0912
commit ea567789d7
2 changed files with 38 additions and 1 deletions
+1 -1
View File
@@ -4,6 +4,6 @@
"version": "0.0.0", "version": "0.0.0",
"packageManager": "pnpm@10.18.3", "packageManager": "pnpm@10.18.3",
"scripts": { "scripts": {
"test": "pnpm --filter @aiquant/shared test" "test": "node scripts/workspace-test.mjs"
} }
} }
+37
View File
@@ -0,0 +1,37 @@
import { spawnSync } from "node:child_process";
const args = process.argv.slice(2);
let filterValue;
const passthroughArgs = [];
for (let index = 0; index < args.length; index += 1) {
const arg = args[index];
if (arg === "--filter") {
filterValue = args[index + 1];
index += 1;
continue;
}
passthroughArgs.push(arg);
}
const commandArgs = ["-r", "--if-present"];
if (filterValue) {
if (!filterValue.includes("/") && !filterValue.includes("*") && !filterValue.startsWith("@")) {
filterValue = `@aiquant/${filterValue}`;
}
commandArgs.push("--filter", filterValue);
}
commandArgs.push("test", "--", ...passthroughArgs);
const result = spawnSync("pnpm", commandArgs, {
cwd: process.cwd(),
shell: true,
stdio: "inherit"
});
process.exit(result.status ?? 1);