Commit 0b41a91f587 for nodejs
commit 0b41a91f587c0a35f774e8d7707a0ab40781d4c0
Author: James M Snell <jasnell@gmail.com>
Date: Wed Nov 25 10:30:33 2026 -0800
lib: fix node --help missing env vars
The help text was dropping the `NODE_ICU_DATA`,
`NODE_OPTIONS`, `OPENSSL_CONF`, `SSL_CERT_DIR`,
and `SSL_CERT_FILE` env vars.
Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Claude
PR-URL: https://github.com/nodejs/node/pull/67719
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
diff --git a/lib/internal/main/print_help.js b/lib/internal/main/print_help.js
index d788c823fb2..e8c0b3737f2 100644
--- a/lib/internal/main/print_help.js
+++ b/lib/internal/main/print_help.js
@@ -77,17 +77,17 @@ const envVars = new SafeMap(ArrayPrototypeConcat([
'libuv\'s threadpool' }],
], hasIntl ? [
['NODE_ICU_DATA', { helpText: 'data path for ICU (Intl object) data' +
- hasSmallICU ? '' : ' (will extend linked-in data)' }],
-] : []), (hasNodeOptions ? [
+ (hasSmallICU ? '' : ' (will extend linked-in data)') }],
+] : [], hasNodeOptions ? [
['NODE_OPTIONS', { helpText: 'set CLI options in the environment via a ' +
'space-separated list' }],
-] : []), hasCrypto ? [
+] : [], hasCrypto ? [
['OPENSSL_CONF', { helpText: 'load OpenSSL configuration from file' }],
['SSL_CERT_DIR', { helpText: 'sets OpenSSL\'s directory of trusted ' +
'certificates when used in conjunction with --use-openssl-ca' }],
['SSL_CERT_FILE', { helpText: 'sets OpenSSL\'s trusted certificate file ' +
'when used in conjunction with --use-openssl-ca' }],
-] : []);
+] : []));
function indent(text, depth) {
diff --git a/test/parallel/test-cli-node-print-help.js b/test/parallel/test-cli-node-print-help.js
index 84704be2104..23752f92d8e 100644
--- a/test/parallel/test-cli-node-print-help.js
+++ b/test/parallel/test-cli-node-print-help.js
@@ -9,6 +9,8 @@ const common = require('../common');
const assert = require('assert');
const { exec, spawn } = require('child_process');
const { once } = require('events');
+const { stripVTControlCharacters } = require('util');
+const { internalBinding } = require('internal/test/binding');
let stdOut;
function startPrintHelpTest() {
@@ -37,6 +39,26 @@ function validateNodePrintHelp() {
];
cliHelpOptions.forEach(testForSubstring);
+
+ // Environment variables are listed at the start of a line in their own
+ // section. Matching on line starts avoids false positives from option help
+ // text that mentions them (e.g. --icu-data-dir mentions NODE_ICU_DATA).
+ const envSection = stripVTControlCharacters(
+ stdOut.slice(stdOut.indexOf('Environment variables:')));
+ const { hasNodeOptions } = internalBinding('config');
+ const envVars = [
+ { compileConstant: HAVE_OPENSSL,
+ names: [ 'OPENSSL_CONF', 'SSL_CERT_DIR', 'SSL_CERT_FILE' ] },
+ { compileConstant: NODE_HAVE_I18N_SUPPORT, names: [ 'NODE_ICU_DATA' ] },
+ { compileConstant: hasNodeOptions, names: [ 'NODE_OPTIONS' ] },
+ ];
+ for (const { compileConstant, names } of envVars) {
+ for (const name of names) {
+ const listed = new RegExp(`^${name}\\s`, 'm').test(envSection);
+ assert.strictEqual(listed, Boolean(compileConstant),
+ `${name} listed: ${listed} in ${envSection}`);
+ }
+ }
}
function testForSubstring(options) {