Skip to content

Commit cb69696

Browse files
committed
test: ensure that CLI options are alphabetical
1 parent 979526f commit cb69696

File tree

2 files changed

+56
-42
lines changed

2 files changed

+56
-42
lines changed

doc/api/cli.md

+43-42
Original file line numberDiff line numberDiff line change
@@ -706,25 +706,6 @@ Make built-in language features like `eval` and `new Function` that generate
706706
code from strings throw an exception instead. This does not affect the Node.js
707707
`node:vm` module.
708708

709-
### `--expose-gc`
710-
711-
<!-- YAML
712-
added:
713-
- v22.3.0
714-
- v20.18.0
715-
-->
716-
717-
> Stability: 1 - Experimental. This flag is inherited from V8 and is subject to
718-
> change upstream.
719-
720-
This flag will expose the gc extension from V8.
721-
722-
```js
723-
if (globalThis.gc) {
724-
globalThis.gc();
725-
}
726-
```
727-
728709
### `--dns-result-order=order`
729710

730711
<!-- YAML
@@ -962,17 +943,6 @@ files with no extension will be treated as WebAssembly if they begin with the
962943
WebAssembly magic number (`\0asm`); otherwise they will be treated as ES module
963944
JavaScript.
964945

965-
### `--experimental-transform-types`
966-
967-
<!-- YAML
968-
added: v22.7.0
969-
-->
970-
971-
> Stability: 1.1 - Active development
972-
973-
Enables the transformation of TypeScript-only syntax into JavaScript code.
974-
Implies `--experimental-strip-types` and `--enable-source-maps`.
975-
976946
### `--experimental-eventsource`
977947

978948
<!-- YAML
@@ -1052,6 +1022,18 @@ following permissions are restricted:
10521022
* WASI - manageable through [`--allow-wasi`][] flag
10531023
* Addons - manageable through [`--allow-addons`][] flag
10541024

1025+
### `--experimental-print-required-tla`
1026+
1027+
<!-- YAML
1028+
added:
1029+
- v22.0.0
1030+
- v20.17.0
1031+
-->
1032+
1033+
If the ES module being `require()`'d contains top-level `await`, this flag
1034+
allows Node.js to evaluate the module, try to locate the
1035+
top-level awaits, and print their location to help users find them.
1036+
10551037
### `--experimental-require-module`
10561038

10571039
<!-- YAML
@@ -1166,6 +1148,17 @@ added: v22.3.0
11661148
11671149
Enable [snapshot testing][] in the test runner.
11681150

1151+
### `--experimental-transform-types`
1152+
1153+
<!-- YAML
1154+
added: v22.7.0
1155+
-->
1156+
1157+
> Stability: 1.1 - Active development
1158+
1159+
Enables the transformation of TypeScript-only syntax into JavaScript code.
1160+
Implies `--experimental-strip-types` and `--enable-source-maps`.
1161+
11691162
### `--experimental-vm-modules`
11701163

11711164
<!-- YAML
@@ -1211,6 +1204,26 @@ added: v22.4.0
12111204

12121205
Enable experimental [`Web Storage`][] support.
12131206

1207+
1208+
### `--expose-gc`
1209+
1210+
<!-- YAML
1211+
added:
1212+
- v22.3.0
1213+
- v20.18.0
1214+
-->
1215+
1216+
> Stability: 1 - Experimental. This flag is inherited from V8 and is subject to
1217+
> change upstream.
1218+
1219+
This flag will expose the gc extension from V8.
1220+
1221+
```js
1222+
if (globalThis.gc) {
1223+
globalThis.gc();
1224+
}
1225+
```
1226+
12141227
### `--force-context-aware`
12151228

12161229
<!-- YAML
@@ -1919,18 +1932,6 @@ changes:
19191932

19201933
Identical to `-e` but prints the result.
19211934

1922-
### `--experimental-print-required-tla`
1923-
1924-
<!-- YAML
1925-
added:
1926-
- v22.0.0
1927-
- v20.17.0
1928-
-->
1929-
1930-
If the ES module being `require()`'d contains top-level `await`, this flag
1931-
allows Node.js to evaluate the module, try to locate the
1932-
top-level awaits, and print their location to help users find them.
1933-
19341935
### `--prof`
19351936

19361937
<!-- YAML

test/parallel/test-cli-node-options-docs.js

+13
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,19 @@ for (const [, envVar, config] of nodeOptionsCC.matchAll(addOptionRE)) {
123123
}
124124
}
125125

126+
{
127+
128+
const start = /^## Options/m;
129+
const end = /^## Environment variables/m;
130+
const filteredCLIText = cliText.slice(cliText.search(start), cliText.search(end)).trim();
131+
const cliOptionPattern = /^### `(--[a-zA-Z0-9-]+)`/mg;
132+
const options = Array.from(filteredCLIText.matchAll(cliOptionPattern)).map(match => match[1]);
133+
134+
const sortedOptions = [...options].sort();
135+
assert.deepStrictEqual(options, sortedOptions, 'CLI options are not in alphabetical order');
136+
137+
}
138+
126139
// add alias handling
127140
manPagesOptions.delete('-trace-events-enabled');
128141

0 commit comments

Comments
 (0)