Skip to content

Commit bc84001

Browse files
guybedforddanielleadams
authored andcommitted
cli: add -C alias for --conditions flag
PR-URL: #38755 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Jan Krems <[email protected]>
1 parent 80c32b7 commit bc84001

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

doc/api/cli.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ $ node --completion-bash > node_bash_completion
8080
$ source node_bash_completion
8181
```
8282

83-
### `--conditions=condition`
83+
### `-C=condition`, `--conditions=condition`
8484
<!-- YAML
8585
added:
8686
- v14.9.0
@@ -89,14 +89,20 @@ added:
8989

9090
> Stability: 1 - Experimental
9191
92-
Enable experimental support for custom conditional exports resolution
92+
Enable experimental support for custom [conditional exports][] resolution
9393
conditions.
9494

9595
Any number of custom string condition names are permitted.
9696

9797
The default Node.js conditions of `"node"`, `"default"`, `"import"`, and
9898
`"require"` will always apply as defined.
9999

100+
For example, to run a module with "development" resolutions:
101+
102+
```console
103+
$ node -C=development app.js
104+
```
105+
100106
### `--cpu-prof`
101107
<!-- YAML
102108
added: v12.0.0
@@ -1368,7 +1374,7 @@ node --require "./a.js" --require "./b.js"
13681374

13691375
Node.js options that are allowed are:
13701376
<!-- node-options-node start -->
1371-
* `--conditions`
1377+
* `--conditions`, `-C`
13721378
* `--diagnostic-dir`
13731379
* `--disable-proto`
13741380
* `--enable-fips`
@@ -1764,6 +1770,7 @@ $ node --max-old-space-size=1536 index.js
17641770
[`tls.DEFAULT_MIN_VERSION`]: tls.md#tls_tls_default_min_version
17651771
[`unhandledRejection`]: process.md#process_event_unhandledrejection
17661772
[`worker_threads.threadId`]: worker_threads.md#worker_threads_worker_threadid
1773+
[conditional exports]: packages.md#packages_conditional_exports
17671774
[context-aware]: addons.md#addons_context_aware_addons
17681775
[customizing ESM specifier resolution]: esm.md#esm_customizing_esm_specifier_resolution_algorithm
17691776
[debugger]: debugger.md

doc/node.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Aborting instead of exiting causes a core file to be generated for analysis.
7878
.It Fl -completion-bash
7979
Print source-able bash completion script for Node.js.
8080
.
81-
.It Fl -conditions Ar string
81+
.It Fl C , Fl -conditions Ar string
8282
Use custom conditional exports conditions.
8383
.Ar string
8484
.

src/node_options.cc

+1
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
292292
"additional user conditions for conditional exports and imports",
293293
&EnvironmentOptions::conditions,
294294
kAllowedInEnvironment);
295+
AddAlias("-C", "--conditions");
295296
AddOption("--diagnostic-dir",
296297
"set dir for all output files"
297298
" (default: current working directory)",

test/es-module/test-esm-custom-exports.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Flags: --conditions=custom-condition --conditions another
1+
// Flags: --conditions=custom-condition -C another
22
import { mustCall } from '../common/index.mjs';
33
import { strictEqual } from 'assert';
44
import { requireFixture, importFixture } from '../fixtures/pkgexports.mjs';

test/parallel/test-process-env-allowed-flags.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const assert = require('assert');
5151
// Assert all "canonical" flags begin with dash(es)
5252
{
5353
process.allowedNodeEnvironmentFlags.forEach((flag) => {
54-
assert(/^--?[a-z0-9._-]+$/.test(flag),
54+
assert(/^--?[a-zA-Z0-9._-]+$/.test(flag),
5555
`Unexpected format for flag ${flag}`);
5656
});
5757
}

0 commit comments

Comments
 (0)