mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 21:28:26 +00:00
fix(ui): unblock docker onboarding build
This commit is contained in:
@@ -1,7 +1,27 @@
|
||||
import { createRequire } from "node:module";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
|
||||
const requireConfig = createRequire(import.meta.url);
|
||||
function resolveNodeRequire(): ((id: string) => NodeJS.Require) | null {
|
||||
const getBuiltinModule = (
|
||||
process as NodeJS.Process & {
|
||||
getBuiltinModule?: (id: string) => unknown;
|
||||
}
|
||||
).getBuiltinModule;
|
||||
if (typeof getBuiltinModule !== "function") {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
const moduleNamespace = getBuiltinModule("module") as {
|
||||
createRequire?: (id: string) => NodeJS.Require;
|
||||
};
|
||||
return typeof moduleNamespace.createRequire === "function"
|
||||
? moduleNamespace.createRequire
|
||||
: null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const requireConfig = resolveNodeRequire()?.(import.meta.url) ?? null;
|
||||
|
||||
export type RedactSensitiveMode = "off" | "tools";
|
||||
|
||||
@@ -110,10 +130,12 @@ function redactText(text: string, patterns: RegExp[]): string {
|
||||
function resolveConfigRedaction(): RedactOptions {
|
||||
let cfg: OpenClawConfig["logging"] | undefined;
|
||||
try {
|
||||
const loaded = requireConfig("../config/config.js") as {
|
||||
loadConfig?: () => OpenClawConfig;
|
||||
};
|
||||
cfg = loaded.loadConfig?.().logging;
|
||||
const loaded = requireConfig?.("../config/config.js") as
|
||||
| {
|
||||
loadConfig?: () => OpenClawConfig;
|
||||
}
|
||||
| undefined;
|
||||
cfg = loaded?.loadConfig?.().logging;
|
||||
} catch {
|
||||
cfg = undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user