mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
doc,test: specify and test CLI option precedence rules
Refs: https://github.com/nodejs/node/pull/35098#issuecomment-689051526 PR-URL: https://github.com/nodejs/node/pull/35106 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Zeyu Yang <himself65@outlook.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
This commit is contained in:
2 files changed
+28
No files matched your search
@@ -34,6 +34,11 @@ dashes (`-`) or underscores (`_`).
|
||||
|
||||
For example, `--pending-deprecation` is equivalent to `--pending_deprecation`.
|
||||
|
||||
If an option that takes a single value, for example `--max-http-header-size`,
|
||||
is passed more than once, then the last passed value will be used. Options
|
||||
from the command line take precedence over options passed through the
|
||||
[`NODE_OPTIONS`][] environment variable.
|
||||
|
||||
### `-`
|
||||
<!-- YAML
|
||||
added: v8.0.0
|
||||
@@ -1487,6 +1492,7 @@ $ node --max-old-space-size=1536 index.js
|
||||
[`--openssl-config`]: #cli_openssl_config_file
|
||||
[`Buffer`]: buffer.html#buffer_class_buffer
|
||||
[`SlowBuffer`]: buffer.html#buffer_class_slowbuffer
|
||||
[`NODE_OPTIONS`]: #cli_node_options_options
|
||||
[`process.setUncaughtExceptionCaptureCallback()`]: process.html#process_process_setuncaughtexceptioncapturecallback_fn
|
||||
[`tls.DEFAULT_MAX_VERSION`]: tls.html#tls_tls_default_max_version
|
||||
[`tls.DEFAULT_MIN_VERSION`]: tls.html#tls_tls_default_min_version
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
// The last option on the command line takes precedence:
|
||||
assert.strictEqual(spawnSync(process.execPath, [
|
||||
'--max-http-header-size=1234',
|
||||
'--max-http-header-size=5678',
|
||||
'-p', 'http.maxHeaderSize'
|
||||
], {
|
||||
encoding: 'utf8'
|
||||
}).stdout.trim(), '5678');
|
||||
|
||||
// The command line takes precedence over NODE_OPTIONS:
|
||||
assert.strictEqual(spawnSync(process.execPath, [
|
||||
'--max-http-header-size=5678',
|
||||
'-p', 'http.maxHeaderSize'
|
||||
], {
|
||||
encoding: 'utf8',
|
||||
env: { ...process.env, NODE_OPTIONS: '--max-http-header-size=1234' }
|
||||
}).stdout.trim(), '5678');
|
||||
Reference in new issue
Block a user