Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Bedford <guybedford@gmail.com>2021-05-21 17:16:12 +0300
committerGuy Bedford <guybedford@gmail.com>2021-05-25 16:13:36 +0300
commit3ad4fa01eb632e46e946a08b04e683f244e85cc9 (patch)
tree127a6cb7b69c28813cdadcc19b2fdcecba98e20a
parentab71af34533a43e4d8d788e8ed678bf572672458 (diff)
cli: add -C alias for --conditions flag
PR-URL: https://github.com/nodejs/node/pull/38755 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com>
-rw-r--r--doc/api/cli.md13
-rw-r--r--doc/node.12
-rw-r--r--src/node_options.cc1
-rw-r--r--test/es-module/test-esm-custom-exports.mjs2
-rw-r--r--test/parallel/test-process-env-allowed-flags.js2
5 files changed, 14 insertions, 6 deletions
diff --git a/doc/api/cli.md b/doc/api/cli.md
index e8fb68a538b..38f72769d9d 100644
--- a/doc/api/cli.md
+++ b/doc/api/cli.md
@@ -80,7 +80,7 @@ $ node --completion-bash > node_bash_completion
$ source node_bash_completion
```
-### `--conditions=condition`
+### `-C=condition`, `--conditions=condition`
<!-- YAML
added:
- v14.9.0
@@ -89,7 +89,7 @@ added:
> Stability: 1 - Experimental
-Enable experimental support for custom conditional exports resolution
+Enable experimental support for custom [conditional exports][] resolution
conditions.
Any number of custom string condition names are permitted.
@@ -97,6 +97,12 @@ Any number of custom string condition names are permitted.
The default Node.js conditions of `"node"`, `"default"`, `"import"`, and
`"require"` will always apply as defined.
+For example, to run a module with "development" resolutions:
+
+```console
+$ node -C=development app.js
+```
+
### `--cpu-prof`
<!-- YAML
added: v12.0.0
@@ -1370,7 +1376,7 @@ node --require "./a.js" --require "./b.js"
Node.js options that are allowed are:
<!-- node-options-node start -->
-* `--conditions`
+* `--conditions`, `-C`
* `--diagnostic-dir`
* `--disable-proto`
* `--enable-fips`
@@ -1766,6 +1772,7 @@ $ node --max-old-space-size=1536 index.js
[`tls.DEFAULT_MIN_VERSION`]: tls.md#tls_tls_default_min_version
[`unhandledRejection`]: process.md#process_event_unhandledrejection
[`worker_threads.threadId`]: worker_threads.md#worker_threads_worker_threadid
+[conditional exports]: packages.md#packages_conditional_exports
[context-aware]: addons.md#addons_context_aware_addons
[customizing ESM specifier resolution]: esm.md#esm_customizing_esm_specifier_resolution_algorithm
[debugger]: debugger.md
diff --git a/doc/node.1 b/doc/node.1
index 5f5a23319cf..a65ec7451a8 100644
--- a/doc/node.1
+++ b/doc/node.1
@@ -78,7 +78,7 @@ Aborting instead of exiting causes a core file to be generated for analysis.
.It Fl -completion-bash
Print source-able bash completion script for Node.js.
.
-.It Fl -conditions Ar string
+.It Fl C , Fl -conditions Ar string
Use custom conditional exports conditions.
.Ar string
.
diff --git a/src/node_options.cc b/src/node_options.cc
index d5c26006887..b8809df58f0 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -292,6 +292,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
"additional user conditions for conditional exports and imports",
&EnvironmentOptions::conditions,
kAllowedInEnvironment);
+ AddAlias("-C", "--conditions");
AddOption("--diagnostic-dir",
"set dir for all output files"
" (default: current working directory)",
diff --git a/test/es-module/test-esm-custom-exports.mjs b/test/es-module/test-esm-custom-exports.mjs
index cf0557fa442..e6023387cf8 100644
--- a/test/es-module/test-esm-custom-exports.mjs
+++ b/test/es-module/test-esm-custom-exports.mjs
@@ -1,4 +1,4 @@
-// Flags: --conditions=custom-condition --conditions another
+// Flags: --conditions=custom-condition -C another
import { mustCall } from '../common/index.mjs';
import { strictEqual } from 'assert';
import { requireFixture, importFixture } from '../fixtures/pkgexports.mjs';
diff --git a/test/parallel/test-process-env-allowed-flags.js b/test/parallel/test-process-env-allowed-flags.js
index 1d50e02d7ab..9337263d5cc 100644
--- a/test/parallel/test-process-env-allowed-flags.js
+++ b/test/parallel/test-process-env-allowed-flags.js
@@ -51,7 +51,7 @@ const assert = require('assert');
// Assert all "canonical" flags begin with dash(es)
{
process.allowedNodeEnvironmentFlags.forEach((flag) => {
- assert(/^--?[a-z0-9._-]+$/.test(flag),
+ assert(/^--?[a-zA-Z0-9._-]+$/.test(flag),
`Unexpected format for flag ${flag}`);
});
}