Skip to content

Commit 13ba2f1

Browse files
committed
fixup!
1 parent 81c1d6f commit 13ba2f1

File tree

3 files changed

+7
-99
lines changed

3 files changed

+7
-99
lines changed

doc/api/cli.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -833,15 +833,6 @@ added: v6.0.0
833833
Enable FIPS-compliant crypto at startup. (Requires Node.js to be built
834834
against FIPS-compatible OpenSSL.)
835835

836-
### `--enable-network-family-autoselection`
837-
838-
<!-- YAML
839-
added: v18.18.0
840-
-->
841-
842-
Enables the family autoselection algorithm unless connection options explicitly
843-
disables it.
844-
845836
### `--enable-source-maps`
846837

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

2297-
### `--report-dir=directory`, `report-directory=directory`
2288+
### `--report-dir=directory`, `--report-directory=directory`
22982289

22992290
<!-- YAML
23002291
added: v11.8.0

doc/node.1

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,10 +512,6 @@ priority than \fB--dns-result-order\fR.
512512
Enable FIPS-compliant crypto at startup. (Requires Node.js to be built
513513
against FIPS-compatible OpenSSL.)
514514
.
515-
.It Fl -enable-network-family-autoselection
516-
Enables the family autoselection algorithm unless connection options explicitly
517-
disables it.
518-
.
519515
.It Fl -enable-source-maps
520516
Enable Source Map support for stack traces.
521517
When using a transpiler, such as TypeScript, stack traces thrown by an
@@ -1189,7 +1185,7 @@ Write reports in a compact format, single-line JSON, more easily consumable
11891185
by log processing systems than the default multi-line format designed for
11901186
human consumption.
11911187
.
1192-
.It Fl -report-dir Ns = Ns Ar directory , Fl eport-directory Ns = Ns Ar directory
1188+
.It Fl -report-dir Ns = Ns Ar directory , Fl -report-directory Ns = Ns Ar directory
11931189
Location at which the report will be generated.
11941190
.
11951191
.It Fl -report-exclude-env

test/parallel/test-cli-node-cli-manpage-options.mjs

Lines changed: 5 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import assert from 'node:assert';
33
import { createReadStream, readFileSync } from 'node:fs';
44
import { createInterface } from 'node:readline';
55
import { resolve, join } from 'node:path';
6-
import { EOL } from 'node:os';
76

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

21-
// TODO(dario-piotrowicz): add the missing flags to the node.1 and remove this set
22-
// (refs: https://github.com/nodejs/node/issues/58895)
23-
const knownFlagsMissingFromManPage = new Set([
24-
'build-snapshot',
25-
'build-snapshot-config',
26-
'disable-sigusr1',
27-
'disable-warning',
28-
'dns-result-order',
29-
'enable-network-family-autoselection',
30-
'env-file-if-exists',
31-
'env-file',
32-
'experimental-network-inspection',
33-
'experimental-print-required-tla',
34-
'experimental-require-module',
35-
'experimental-sea-config',
36-
'experimental-worker-inspection',
37-
'expose-gc',
38-
'force-node-api-uncaught-exceptions-policy',
39-
'import',
40-
'network-family-autoselection-attempt-timeout',
41-
'no-async-context-frame',
42-
'no-experimental-detect-module',
43-
'no-experimental-global-navigator',
44-
'no-experimental-require-module',
45-
'no-network-family-autoselection',
46-
'openssl-legacy-provider',
47-
'openssl-shared-config',
48-
'report-dir',
49-
'report-directory',
50-
'report-exclude-env',
51-
'report-exclude-network',
52-
'run',
53-
'snapshot-blob',
54-
'trace-env',
55-
'trace-env-js-stack',
56-
'trace-env-native-stack',
57-
'trace-require-module',
58-
'use-system-ca',
59-
'watch-preserve-output',
60-
]);
61-
62-
const optionsEncountered = { dash: 0, dashDash: 0, named: 0 };
6320
let insideOptionsSection = false;
6421

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

8643
if (insideOptionsSection && isOptionLineRegex.test(line)) {
87-
if (line === '### `-`') {
88-
if (!manPageContents.includes(`${EOL}.It Sy -${EOL}`)) {
89-
throw new Error(`The \`-\` flag is missing in the \`doc/node.1\` file`);
90-
}
91-
optionsEncountered.dash++;
92-
continue;
93-
}
94-
95-
if (line === '### `--`') {
96-
if (!manPageContents.includes(`${EOL}.It Fl -${EOL}`)) {
97-
throw new Error(`The \`--\` flag is missing in the \`doc/node.1\` file`);
98-
}
99-
optionsEncountered.dashDash++;
100-
continue;
101-
}
102-
10344
const flagNames = extractFlagNames(line);
45+
const flagMatcher = new RegExp(`^\\.It ${flagNames.map((f) => `Fl ${f}.*`).join(', ')}$`, 'm');
10446

105-
optionsEncountered.named += flagNames.length;
106-
107-
const manLine = `.It ${flagNames
108-
.map((flag) => `Fl ${flag.length > 1 ? '-' : ''}${flag}`)
109-
.join(' , ')}`;
110-
111-
if (
112-
// Note: we don't check the full line (note the EOL only at the beginning) because
113-
// options can have arguments and we do want to ignore those
114-
!manPageContents.includes(`${EOL}${manLine}`) &&
115-
!flagNames.every((flag) => knownFlagsMissingFromManPage.has(flag))) {
47+
if (!manPageContents.match(flagMatcher)) {
11648
assert.fail(
11749
`The following flag${
11850
flagNames.length === 1 ? '' : 's'
11951
} (present in \`doc/api/cli.md\`) ${flagNames.length === 1 ? 'is' : 'are'} missing in the \`doc/node.1\` file: ${
120-
flagNames.map((flag) => `"${flag}"`).join(', ')
52+
flagNames.map((flag) => `"-${flag}"`).join(', ')
12153
}`
12254
);
12355
}
12456
}
12557
}
12658

127-
assert.strictEqual(optionsEncountered.dash, 1);
128-
129-
assert.strictEqual(optionsEncountered.dashDash, 1);
130-
131-
assert(optionsEncountered.named > 0,
132-
'Unexpectedly not even a single cli flag/option was detected when scanning the `doc/cli.md` file'
133-
);
134-
13559
/**
13660
* Function that given a string containing backtick enclosed cli flags
13761
* separated by `, ` returns the name of flags present in the string
@@ -145,11 +69,8 @@ function extractFlagNames(str) {
14569
return [];
14670
}
14771
return match.map((flag) => {
148-
// Remove the backticks from the flag
149-
flag = flag.slice(1, -1);
150-
151-
// Remove the dash or dashes
152-
flag = flag.replace(/^--?/, '');
72+
// Remove the backticks, and leading dash from the flag
73+
flag = flag.slice(2, -1);
15374

15475
// If the flag contains parameters make sure to remove those
15576
const nameDelimiters = ['=', ' ', '['];

0 commit comments

Comments
 (0)