mirror of
https://github.com/nodejs/node.git
synced 2025-05-01 08:42:45 +00:00

test-cli-bad-options.js uses `spawnSync()` but renames it as `spawn()` which caused me a bit of confusion for a bit until I realized what was going on. Rename the variable `spawnSync()` for readability/maintainability. PR-URL: https://github.com/nodejs/node/pull/41327 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
28 lines
680 B
JavaScript
28 lines
680 B
JavaScript
'use strict';
|
|
require('../common');
|
|
|
|
// Tests that node exits consistently on bad option syntax.
|
|
|
|
const assert = require('assert');
|
|
const { spawnSync } = require('child_process');
|
|
|
|
if (process.features.inspector) {
|
|
requiresArgument('--inspect-port');
|
|
requiresArgument('--inspect-port=');
|
|
requiresArgument('--debug-port');
|
|
requiresArgument('--debug-port=');
|
|
}
|
|
requiresArgument('--eval');
|
|
|
|
function requiresArgument(option) {
|
|
const r = spawnSync(process.execPath, [option], { encoding: 'utf8' });
|
|
|
|
assert.strictEqual(r.status, 9);
|
|
|
|
const msg = r.stderr.split(/\r?\n/)[0];
|
|
assert.strictEqual(
|
|
msg,
|
|
`${process.execPath}: ${option} requires an argument`
|
|
);
|
|
}
|