mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-11 09:11:13 +00:00
test: route vitest through node launcher
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { createRequire } from "node:module";
|
||||
import path from "node:path";
|
||||
import { spawnPnpmRunner } from "./pnpm-runner.mjs";
|
||||
|
||||
const TRUTHY_ENV_VALUES = new Set(["1", "true", "yes", "on"]);
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
function isTruthyEnvValue(value) {
|
||||
return TRUTHY_ENV_VALUES.has(value?.trim().toLowerCase() ?? "");
|
||||
@@ -14,6 +17,11 @@ export function resolveVitestNodeArgs(env = process.env) {
|
||||
return ["--no-maglev"];
|
||||
}
|
||||
|
||||
export function resolveVitestCliEntry() {
|
||||
const vitestPackageJson = require.resolve("vitest/package.json");
|
||||
return path.join(path.dirname(vitestPackageJson), "vitest.mjs");
|
||||
}
|
||||
|
||||
function main(argv = process.argv.slice(2), env = process.env) {
|
||||
if (argv.length === 0) {
|
||||
console.error("usage: node scripts/run-vitest.mjs <vitest args...>");
|
||||
@@ -21,8 +29,7 @@ function main(argv = process.argv.slice(2), env = process.env) {
|
||||
}
|
||||
|
||||
const child = spawnPnpmRunner({
|
||||
pnpmArgs: ["exec", "vitest", ...argv],
|
||||
nodeArgs: resolveVitestNodeArgs(env),
|
||||
pnpmArgs: ["exec", "node", ...resolveVitestNodeArgs(env), resolveVitestCliEntry(), ...argv],
|
||||
env,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user