node/test/parallel/test-cli-options-precedence.js
Anna Henningsen 02e925553d
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>
2020-09-11 10:31:35 +02:00

23 lines
662 B
JavaScript

'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');