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,test: fix config file parsing for flags defaulted to true · nodejs/node@ef89c2f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_config_file.cc
  • test
    • fixtures/rc
      • warnings-false.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
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ ParseResult ConfigReader::ProcessOptionValue(
5555
if (result) {
5656
// If the value is true, we need to set the flag
5757
output->push_back(option_name);
58+
} else {
59+
// Ensure negation is made putting the "--no-" prefix
60+
output->push_back("--no-" +
61+
option_name.substr(2, option_name.size() - 2));
5862
}
5963

6064
break;
Collapse file

‎test/fixtures/rc/warnings-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+
"warnings": false
4+
}
5+
}
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-config-file.js
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ test('should parse boolean flag', async () => {
6060
strictEqual(result.code, 0);
6161
});
6262

63+
test('should parse boolean flag defaulted to true', async () => {
64+
const result = await spawnPromisified(process.execPath, [
65+
'--experimental-config-file',
66+
fixtures.path('rc/warnings-false.json'),
67+
'-p', 'process.emitWarning("A warning")',
68+
]);
69+
strictEqual(result.stderr, '');
70+
strictEqual(result.stdout, 'undefined\n');
71+
strictEqual(result.code, 0);
72+
});
73+
6374
test('should throw an error when a flag is declared twice', async () => {
6475
const result = await spawnPromisified(process.execPath, [
6576
'--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.