Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/internal/main/print_help.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
22 changes: 22 additions & 0 deletions test/parallel/test-cli-node-print-help.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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) {
Expand Down
Loading