mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 17:08:27 +00:00
fix(ui): unblock docker onboarding build
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import fs from "node:fs";
|
||||
import { createRequire } from "node:module";
|
||||
import path from "node:path";
|
||||
import { Logger as TsLogger } from "tslog";
|
||||
import type { OpenClawConfig } from "../config/types.js";
|
||||
@@ -16,7 +15,28 @@ const LOG_PREFIX = "openclaw";
|
||||
const LOG_SUFFIX = ".log";
|
||||
const MAX_LOG_AGE_MS = 24 * 60 * 60 * 1000; // 24h
|
||||
|
||||
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 LoggerSettings = {
|
||||
level?: LogLevel;
|
||||
@@ -55,10 +75,12 @@ function resolveSettings(): ResolvedSettings {
|
||||
(loggingState.overrideSettings as LoggerSettings | null) ?? readLoggingConfig();
|
||||
if (!cfg) {
|
||||
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