diff --git a/package.json b/package.json index 922dad9..8cacc00 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,6 @@ "version": "0.0.0", "packageManager": "pnpm@10.18.3", "scripts": { - "test": "pnpm --filter @aiquant/shared test" + "test": "node scripts/workspace-test.mjs" } } diff --git a/scripts/workspace-test.mjs b/scripts/workspace-test.mjs new file mode 100644 index 0000000..d673e05 --- /dev/null +++ b/scripts/workspace-test.mjs @@ -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);