From 6f79b0ac09bbe944fc04a3a564ca5073557c2d91 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Mon, 23 Nov 2026 00:20:06 +0000 Subject: [PATCH] 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 Assisted-by: Claude --- lib/internal/main/print_help.js | 8 ++++---- test/parallel/test-cli-node-print-help.js | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/lib/internal/main/print_help.js b/lib/internal/main/print_help.js index d788c823fb2c..e8c0b3737f26 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 84704be2104a..23752f92d8e1 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) {