src: enhance error messages for unknown options

PR-URL: https://github.com/nodejs/node/pull/58677
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Pietro Marchini authored and Michaël Zasso committed 2025-06-16 08:51:14 +02:00
1 parent ec808b3e06
commit dfb0144490
2 files changed
+4 -4

No files matched your search

+1 -1
View File
@@ -200,7 +200,7 @@ ParseResult ConfigReader::ParseOptions(
} else {
FPrintF(stderr,
"Unknown or not allowed option %s for namespace %s\n",
option_key.data(),
option_key,
namespace_name.c_str());
return ParseResult::InvalidContent;
}
+3 -3
View File
@@ -154,7 +154,7 @@ test('should throw at unknown flag', async () => {
fixtures.path('rc/unknown-flag.json'),
'-p', '"Hello, World!"',
]);
match(result.stderr, /Unknown or not allowed option some-unknown-flag/);
match(result.stderr, /Unknown or not allowed option some-unknown-flag for namespace nodeOptions/);
strictEqual(result.stdout, '');
strictEqual(result.code, 9);
});
@@ -166,7 +166,7 @@ test('should throw at flag not available in NODE_OPTIONS', async () => {
fixtures.path('rc/not-node-options-flag.json'),
'-p', '"Hello, World!"',
]);
match(result.stderr, /Unknown or not allowed option test/);
match(result.stderr, /Unknown or not allowed option test for namespace nodeOptions/);
strictEqual(result.stdout, '');
strictEqual(result.code, 9);
});
@@ -401,7 +401,7 @@ describe('namespace-scoped options', () => {
fixtures.path('rc/unknown-flag-namespace.json'),
'-p', '"Hello, World!"',
]);
match(result.stderr, /Unknown or not allowed option unknown-flag/);
match(result.stderr, /Unknown or not allowed option unknown-flag for namespace testRunner/);
strictEqual(result.stdout, '');
strictEqual(result.code, 9);
});