mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 19:20:22 +00:00
fix: resolve live config paths in status and gateway metadata (#39952)
* fix: resolve live config paths in status and gateway metadata * fix: resolve remaining runtime config path references * test: cover gateway config.set config path response
This commit is contained in:
25
src/config/logging.test.ts
Normal file
25
src/config/logging.test.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
createConfigIO: vi.fn().mockReturnValue({
|
||||
configPath: "/tmp/openclaw-dev/openclaw.json",
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("./io.js", () => ({
|
||||
createConfigIO: mocks.createConfigIO,
|
||||
}));
|
||||
|
||||
import { formatConfigPath, logConfigUpdated } from "./logging.js";
|
||||
|
||||
describe("config logging", () => {
|
||||
it("formats the live config path when no explicit path is provided", () => {
|
||||
expect(formatConfigPath()).toBe("/tmp/openclaw-dev/openclaw.json");
|
||||
});
|
||||
|
||||
it("logs the live config path when no explicit path is provided", () => {
|
||||
const runtime = { log: vi.fn() };
|
||||
logConfigUpdated(runtime as never);
|
||||
expect(runtime.log).toHaveBeenCalledWith("Updated /tmp/openclaw-dev/openclaw.json");
|
||||
});
|
||||
});
|
||||
@@ -1,18 +1,18 @@
|
||||
import type { RuntimeEnv } from "../runtime.js";
|
||||
import { displayPath } from "../utils.js";
|
||||
import { CONFIG_PATH } from "./paths.js";
|
||||
import { createConfigIO } from "./io.js";
|
||||
|
||||
type LogConfigUpdatedOptions = {
|
||||
path?: string;
|
||||
suffix?: string;
|
||||
};
|
||||
|
||||
export function formatConfigPath(path: string = CONFIG_PATH): string {
|
||||
export function formatConfigPath(path: string = createConfigIO().configPath): string {
|
||||
return displayPath(path);
|
||||
}
|
||||
|
||||
export function logConfigUpdated(runtime: RuntimeEnv, opts: LogConfigUpdatedOptions = {}): void {
|
||||
const path = formatConfigPath(opts.path ?? CONFIG_PATH);
|
||||
const path = formatConfigPath(opts.path ?? createConfigIO().configPath);
|
||||
const suffix = opts.suffix ? ` ${opts.suffix}` : "";
|
||||
runtime.log(`Updated ${path}${suffix}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user