Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 6 additions & 2 deletions src/node_config_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ ParseResult ConfigReader::ParseNodeOptions(
FPrintF(stderr, "Invalid value for %s\n", it->first.c_str());
return ParseResult::InvalidContent;
}
node_options_.push_back(it->first + "=" +
(result ? "true" : "false"));

if (result) {
// If the value is true, we need to set the flag
node_options_.push_back(it->first);
}

break;
}
// String array can allow both string and array types
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/rc/inspect-false.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"nodeOptions": {
"inspect": false
}
}
5 changes: 5 additions & 0 deletions test/fixtures/rc/inspect-true.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"nodeOptions": {
"inspect": true
}
}
26 changes: 26 additions & 0 deletions test/parallel/test-config-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,32 @@ test('host port flag should be parsed correctly', { skip: !process.features.insp
strictEqual(result.code, 0);
});

test('--inspect=true should be parsed correctly', { skip: !process.features.inspector }, async () => {
const result = await spawnPromisified(process.execPath, [
'--no-warnings',
'--expose-internals',
'--experimental-config-file',
fixtures.path('rc/inspect-true.json'),
'-p', 'require("internal/options").getOptionValue("--inspect")',
]);
match(result.stderr, /^Debugger listening on (ws:\/\/[^\s]+)/);
strictEqual(result.stdout, 'true\n');
strictEqual(result.code, 0);
});

test('--inspect=false should be parsed correctly', { skip: !process.features.inspector }, async () => {
const result = await spawnPromisified(process.execPath, [
'--no-warnings',
'--expose-internals',
'--experimental-config-file',
fixtures.path('rc/inspect-false.json'),
'-p', 'require("internal/options").getOptionValue("--inspect")',
]);
strictEqual(result.stderr, '');
strictEqual(result.stdout, 'false\n');
strictEqual(result.code, 0);
});

test('no op flag should throw', async () => {
const result = await spawnPromisified(process.execPath, [
'--no-warnings',
Expand Down
Loading