test: ensure cli.md is in alphabetical order

Co-authored-by: RedYetiDev <redyetidev@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/56025
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Antoine du HamelandRedYetiDev authored and Michaël Zasso committed 2024-12-06 15:26:41 +01:00
1 parent 59d6891872
commit 046e642a80
2 files changed
+119 -104

No files matched your search

@@ -123,6 +123,21 @@ for (const [, envVar, config] of nodeOptionsCC.matchAll(addOptionRE)) {
}
}
{
const sections = /^## (.+)$/mg;
const cliOptionPattern = /^### (?:`-\w.*`, )?`([^`]+)`/mg;
let match;
let previousIndex = 0;
do {
const sectionTitle = match?.[1];
match = sections.exec(cliText);
const filteredCLIText = cliText.slice(previousIndex, match?.index);
const options = Array.from(filteredCLIText.matchAll(cliOptionPattern), (match) => match[1]);
assert.deepStrictEqual(options, options.toSorted(), `doc/api/cli.md ${sectionTitle} subsections are not in alphabetical order`);
previousIndex = match?.index;
} while (match);
}
// add alias handling
manPagesOptions.delete('-trace-events-enabled');