Skip to content

Commit

Permalink
test: ensure that CLI options are alphabetical
Browse files Browse the repository at this point in the history
  • Loading branch information
RedYetiDev committed Nov 9, 2024
1 parent 0a00217 commit 6369aa2
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 42 deletions.
85 changes: 43 additions & 42 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -706,25 +706,6 @@ Make built-in language features like `eval` and `new Function` that generate
code from strings throw an exception instead. This does not affect the Node.js
`node:vm` module.

### `--expose-gc`

<!-- YAML
added:
- v22.3.0
- v20.18.0
-->

> Stability: 1 - Experimental. This flag is inherited from V8 and is subject to
> change upstream.
This flag will expose the gc extension from V8.

```js
if (globalThis.gc) {
globalThis.gc();
}
```

### `--dns-result-order=order`

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

### `--experimental-transform-types`

<!-- YAML
added: v22.7.0
-->

> Stability: 1.1 - Active development
Enables the transformation of TypeScript-only syntax into JavaScript code.
Implies `--experimental-strip-types` and `--enable-source-maps`.

### `--experimental-eventsource`

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

### `--experimental-print-required-tla`

<!-- YAML
added:
- v22.0.0
- v20.17.0
-->

If the ES module being `require()`'d contains top-level `await`, this flag
allows Node.js to evaluate the module, try to locate the
top-level awaits, and print their location to help users find them.

### `--experimental-require-module`

<!-- YAML
Expand Down Expand Up @@ -1166,6 +1148,17 @@ added: v22.3.0
Enable [snapshot testing][] in the test runner.

### `--experimental-transform-types`

<!-- YAML
added: v22.7.0
-->

> Stability: 1.1 - Active development
Enables the transformation of TypeScript-only syntax into JavaScript code.
Implies `--experimental-strip-types` and `--enable-source-maps`.

### `--experimental-vm-modules`

<!-- YAML
Expand Down Expand Up @@ -1211,6 +1204,26 @@ added: v22.4.0

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


### `--expose-gc`

<!-- YAML
added:
- v22.3.0
- v20.18.0
-->

> Stability: 1 - Experimental. This flag is inherited from V8 and is subject to
> change upstream.
This flag will expose the gc extension from V8.

```js
if (globalThis.gc) {
globalThis.gc();
}
```

### `--force-context-aware`

<!-- YAML
Expand Down Expand Up @@ -1919,18 +1932,6 @@ changes:

Identical to `-e` but prints the result.

### `--experimental-print-required-tla`

<!-- YAML
added:
- v22.0.0
- v20.17.0
-->

If the ES module being `require()`'d contains top-level `await`, this flag
allows Node.js to evaluate the module, try to locate the
top-level awaits, and print their location to help users find them.

### `--prof`

<!-- YAML
Expand Down
13 changes: 13 additions & 0 deletions test/parallel/test-cli-node-options-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ for (const [, envVar, config] of nodeOptionsCC.matchAll(addOptionRE)) {
}
}

{

const start = /^## Options/m;
const end = /^## Environment variables/m;
const filteredCLIText = cliText.slice(cliText.search(start), cliText.search(end)).trim();
const cliOptionPattern = /^### `(--[a-zA-Z0-9-]+)`/mg;
const options = Array.from(filteredCLIText.matchAll(cliOptionPattern)).map(match => match[1]);

const sortedOptions = [...options].sort();
assert.deepStrictEqual(options, sortedOptions, 'CLI options are not in alphabetical order');

}

// add alias handling
manPagesOptions.delete('-trace-events-enabled');

Expand Down

0 comments on commit 6369aa2

Please sign in to comment.