mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-22 22:52:03 +00:00
refactor: dedupe test helpers and script warning filter
This commit is contained in:
@@ -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)), "..");
|
||||
|
||||
Reference in New Issue
Block a user