GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: improve parsing of boolean options · nodejs/node@130eaa2

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_config_file.cc
  • test
    • fixtures/rc
      • inspect-false.json
      • inspect-true.json
    • parallel
      • test-config-file.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_config_file.cc‎

Copy file name to clipboardExpand all lines: src/node_config_file.cc
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,12 @@ ParseResult ConfigReader::ParseNodeOptions(
5959
FPrintF(stderr, "Invalid value for %s\n", it->first.c_str());
6060
return ParseResult::InvalidContent;
6161
}
62-
node_options_.push_back(it->first + "=" +
63-
(result ? "true" : "false"));
62+
63+
if (result) {
64+
// If the value is true, we need to set the flag
65+
node_options_.push_back(it->first);
66+
}
67+
6468
break;
6569
}
6670
// String array can allow both string and array types
Collapse file

‎test/fixtures/rc/inspect-false.json‎

Copy file name to clipboard
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"nodeOptions": {
3+
"inspect": false
4+
}
5+
}
Collapse file

‎test/fixtures/rc/inspect-true.json‎

Copy file name to clipboard
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"nodeOptions": {
3+
"inspect": true
4+
}
5+
}
Collapse file

‎test/parallel/test-config-file.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-config-file.js
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,30 @@ test('host port flag should be parsed correctly', { skip: !process.features.insp
232232
strictEqual(result.code, 0);
233233
});
234234

235+
test('--inspect=true should be parsed correctly', { skip: !process.features.inspector }, async () => {
236+
const result = await spawnPromisified(process.execPath, [
237+
'--no-warnings',
238+
'--experimental-config-file',
239+
fixtures.path('rc/inspect-true.json'),
240+
'-p', 'require("node:inspector").url()',
241+
]);
242+
match(result.stderr, /^Debugger listening on (ws:\/\/[^\s]+)/);
243+
match(result.stdout, /ws:\/\/[^\s]+/);
244+
strictEqual(result.code, 0);
245+
});
246+
247+
test('--inspect=false should be parsed correctly', { skip: !process.features.inspector }, async () => {
248+
const result = await spawnPromisified(process.execPath, [
249+
'--no-warnings',
250+
'--experimental-config-file',
251+
fixtures.path('rc/inspect-false.json'),
252+
'-p', 'require("node:inspector").url()',
253+
]);
254+
strictEqual(result.stderr, '');
255+
strictEqual(result.stdout, 'undefined\n');
256+
strictEqual(result.code, 0);
257+
});
258+
235259
test('no op flag should throw', async () => {
236260
const result = await spawnPromisified(process.execPath, [
237261
'--no-warnings',

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.