Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup!
  • Loading branch information
avivkeller committed Jan 27, 2026
commit 13ba2f1955bb0a9fe6f69649bdb8bd85b1cbc9ec
11 changes: 1 addition & 10 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -833,15 +833,6 @@ added: v6.0.0
Enable FIPS-compliant crypto at startup. (Requires Node.js to be built
against FIPS-compatible OpenSSL.)

### `--enable-network-family-autoselection`

<!-- YAML
added: v18.18.0
-->

Enables the family autoselection algorithm unless connection options explicitly
disables it.

Comment thread
avivkeller marked this conversation as resolved.
### `--enable-source-maps`

<!-- YAML
Expand Down Expand Up @@ -2294,7 +2285,7 @@ Write reports in a compact format, single-line JSON, more easily consumable
by log processing systems than the default multi-line format designed for
human consumption.

### `--report-dir=directory`, `report-directory=directory`
### `--report-dir=directory`, `--report-directory=directory`

<!-- YAML
added: v11.8.0
Expand Down
6 changes: 1 addition & 5 deletions doc/node.1
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,6 @@ priority than \fB--dns-result-order\fR.
Enable FIPS-compliant crypto at startup. (Requires Node.js to be built
against FIPS-compatible OpenSSL.)
.
.It Fl -enable-network-family-autoselection
Enables the family autoselection algorithm unless connection options explicitly
disables it.
.
.It Fl -enable-source-maps
Enable Source Map support for stack traces.
When using a transpiler, such as TypeScript, stack traces thrown by an
Expand Down Expand Up @@ -1189,7 +1185,7 @@ Write reports in a compact format, single-line JSON, more easily consumable
by log processing systems than the default multi-line format designed for
human consumption.
.
.It Fl -report-dir Ns = Ns Ar directory , Fl eport-directory Ns = Ns Ar directory
.It Fl -report-dir Ns = Ns Ar directory , Fl -report-directory Ns = Ns Ar directory
Location at which the report will be generated.
.
.It Fl -report-exclude-env
Expand Down
89 changes: 5 additions & 84 deletions test/parallel/test-cli-node-cli-manpage-options.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import assert from 'node:assert';
import { createReadStream, readFileSync } from 'node:fs';
import { createInterface } from 'node:readline';
import { resolve, join } from 'node:path';
import { EOL } from 'node:os';

// This test checks that all the CLI flags defined in the public CLI documentation (doc/api/cli.md)
// are also documented in the manpage file (doc/node.1)
Expand All @@ -18,48 +17,6 @@ const cliMdContentsStream = createReadStream(cliMdPath);
const manPagePath = join(rootDir, 'doc', 'node.1');
const manPageContents = readFileSync(manPagePath, { encoding: 'utf8' });

// TODO(dario-piotrowicz): add the missing flags to the node.1 and remove this set
// (refs: https://github.com/nodejs/node/issues/58895)
const knownFlagsMissingFromManPage = new Set([
'build-snapshot',
'build-snapshot-config',
'disable-sigusr1',
'disable-warning',
'dns-result-order',
'enable-network-family-autoselection',
'env-file-if-exists',
'env-file',
'experimental-network-inspection',
'experimental-print-required-tla',
'experimental-require-module',
'experimental-sea-config',
'experimental-worker-inspection',
'expose-gc',
'force-node-api-uncaught-exceptions-policy',
'import',
'network-family-autoselection-attempt-timeout',
'no-async-context-frame',
'no-experimental-detect-module',
'no-experimental-global-navigator',
'no-experimental-require-module',
'no-network-family-autoselection',
'openssl-legacy-provider',
'openssl-shared-config',
'report-dir',
'report-directory',
'report-exclude-env',
'report-exclude-network',
'run',
'snapshot-blob',
'trace-env',
'trace-env-js-stack',
'trace-env-native-stack',
'trace-require-module',
'use-system-ca',
'watch-preserve-output',
]);

const optionsEncountered = { dash: 0, dashDash: 0, named: 0 };
let insideOptionsSection = false;

const rl = createInterface({
Expand All @@ -84,54 +41,21 @@ for await (const line of rl) {
}

if (insideOptionsSection && isOptionLineRegex.test(line)) {
if (line === '### `-`') {
if (!manPageContents.includes(`${EOL}.It Sy -${EOL}`)) {
throw new Error(`The \`-\` flag is missing in the \`doc/node.1\` file`);
}
optionsEncountered.dash++;
continue;
}

if (line === '### `--`') {
if (!manPageContents.includes(`${EOL}.It Fl -${EOL}`)) {
throw new Error(`The \`--\` flag is missing in the \`doc/node.1\` file`);
}
optionsEncountered.dashDash++;
continue;
}

const flagNames = extractFlagNames(line);
const flagMatcher = new RegExp(`^\\.It ${flagNames.map((f) => `Fl ${f}.*`).join(', ')}$`, 'm');

optionsEncountered.named += flagNames.length;

const manLine = `.It ${flagNames
.map((flag) => `Fl ${flag.length > 1 ? '-' : ''}${flag}`)
.join(' , ')}`;

if (
// Note: we don't check the full line (note the EOL only at the beginning) because
// options can have arguments and we do want to ignore those
!manPageContents.includes(`${EOL}${manLine}`) &&
!flagNames.every((flag) => knownFlagsMissingFromManPage.has(flag))) {
if (!manPageContents.match(flagMatcher)) {
assert.fail(
`The following flag${
flagNames.length === 1 ? '' : 's'
} (present in \`doc/api/cli.md\`) ${flagNames.length === 1 ? 'is' : 'are'} missing in the \`doc/node.1\` file: ${
flagNames.map((flag) => `"${flag}"`).join(', ')
flagNames.map((flag) => `"-${flag}"`).join(', ')
}`
);
}
}
}

assert.strictEqual(optionsEncountered.dash, 1);

assert.strictEqual(optionsEncountered.dashDash, 1);

assert(optionsEncountered.named > 0,
'Unexpectedly not even a single cli flag/option was detected when scanning the `doc/cli.md` file'
);

/**
* Function that given a string containing backtick enclosed cli flags
* separated by `, ` returns the name of flags present in the string
Expand All @@ -145,11 +69,8 @@ function extractFlagNames(str) {
return [];
}
return match.map((flag) => {
// Remove the backticks from the flag
flag = flag.slice(1, -1);

// Remove the dash or dashes
flag = flag.replace(/^--?/, '');
// Remove the backticks, and leading dash from the flag
flag = flag.slice(2, -1);

// If the flag contains parameters make sure to remove those
const nameDelimiters = ['=', ' ', '['];
Expand Down
Loading