mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-30 11:11:02 +00:00
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import fs from "node:fs/promises";
|
|
import path from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
const DOCS_WITH_CONFIG_PATH_EXAMPLES = [
|
|
"docs/cli/config.md",
|
|
"docs/tools/exec.md",
|
|
"docs/nodes/index.md",
|
|
];
|
|
|
|
function findUnquotedBracketPathExamples(markdown: string, docPath: string): string[] {
|
|
const failures: string[] = [];
|
|
|
|
for (const [index, line] of markdown.split(/\r?\n/).entries()) {
|
|
const match = line.match(/\bopenclaw\s+config\s+(?:get|set|unset)\s+(\S+)/);
|
|
if (!match) {
|
|
continue;
|
|
}
|
|
|
|
const pathArg = match[1];
|
|
if (pathArg.includes("[") && !pathArg.startsWith("'") && !pathArg.startsWith('"')) {
|
|
failures.push(`${docPath}:${index + 1}: ${pathArg}`);
|
|
}
|
|
}
|
|
|
|
return failures;
|
|
}
|
|
|
|
describe("config path docs", () => {
|
|
it("quotes bracket-notation config paths in shell examples", async () => {
|
|
const failures: string[] = [];
|
|
|
|
for (const docPath of DOCS_WITH_CONFIG_PATH_EXAMPLES) {
|
|
const markdown = await fs.readFile(path.join(process.cwd(), docPath), "utf8");
|
|
failures.push(...findUnquotedBracketPathExamples(markdown, docPath));
|
|
}
|
|
|
|
expect(failures).toEqual([]);
|
|
});
|
|
});
|