refactor: dedupe test helpers and script warning filter

This commit is contained in:
Peter Steinberger
2026-04-08 14:12:50 +01:00
parent 6276530dc2
commit 3dd19a1705
5 changed files with 115 additions and 190 deletions

View File

@@ -3,41 +3,9 @@ import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
import { installProcessWarningFilter } from "./process-warning-filter.mjs";
import { stageBundledPluginRuntime } from "./stage-bundled-plugin-runtime.mjs";
const warningFilterKey = Symbol.for("openclaw.warning-filter");
function installProcessWarningFilter() {
if (globalThis[warningFilterKey]?.installed) {
return;
}
const originalEmitWarning = process.emitWarning.bind(process);
process.emitWarning = (...args) => {
const [warningArg, secondArg, thirdArg] = args;
const warning =
warningArg instanceof Error
? {
name: warningArg.name,
message: warningArg.message,
code: warningArg.code,
}
: {
name: typeof secondArg === "string" ? secondArg : secondArg?.type,
message: typeof warningArg === "string" ? warningArg : undefined,
code: typeof thirdArg === "string" ? thirdArg : secondArg?.code,
};
if (warning.code === "DEP0040" && warning.message?.includes("punycode")) {
return;
}
return Reflect.apply(originalEmitWarning, process, args);
};
globalThis[warningFilterKey] = { installed: true };
}
installProcessWarningFilter();
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");