Skip to content
Merged
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: 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
}
}
24 changes: 24 additions & 0 deletions test/parallel/test-config-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,30 @@ 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',
'--experimental-config-file',
fixtures.path('rc/inspect-true.json'),
'-p', 'require("node:inspector").url()',
]);
match(result.stderr, /^Debugger listening on (ws:\/\/[^\s]+)/);
match(result.stdout, /ws:\/\/[^\s]+/);
strictEqual(result.code, 0);
});

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

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