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
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/node_config_file.cc +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -55,6 +55,10 @@ ParseResult ConfigReader::ProcessOptionValue( |
55 | 55 | if (result) { |
56 | 56 | // If the value is true, we need to set the flag |
57 | 57 | 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)); |
58 | 62 | } |
59 | 63 |
|
60 | 64 | break; |
|
Collapse file
Copy file name to clipboard +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +{ |
| 2 | + "nodeOptions": { |
| 3 | + "warnings": false |
| 4 | + } |
| 5 | +} |
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-config-file.js +11Lines changed: 11 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -60,6 +60,17 @@ test('should parse boolean flag', async () => { |
60 | 60 | strictEqual(result.code, 0); |
61 | 61 | }); |
62 | 62 |
|
| 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 | + |
63 | 74 | test('should throw an error when a flag is declared twice', async () => { |
64 | 75 | const result = await spawnPromisified(process.execPath, [ |
65 | 76 | '--no-warnings', |
|