Skip to content

Commit a0433ee

Browse files
author
Aakash
committed
lib: remove prefix from node.config schema namespaces
Remove redundant prefixes from keys in test and watch namespaces in the node.config JSON schema. Keys like test-concurrency and watch-path are now shown as concurrency and path within their respective namespaces, with the prefixed versions kept as aliases for backward compatibility. Refs: #60904
1 parent 443ec83 commit a0433ee

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

lib/internal/options.js

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,27 @@ function generateConfigJsonSchema() {
106106

107107
// Add all options for this namespace
108108
for (const { 0: optionName, 1: optionType } of optionsMap) {
109-
const keyWithoutPrefix = StringPrototypeReplace(optionName, '--', '');
110-
namespaceProperties[keyWithoutPrefix] = createPropertyForType(optionType);
109+
let keyWithoutPrefix = StringPrototypeReplace(optionName, '--', '');
110+
const originalKey = keyWithoutPrefix;
111+
const propertySchema = createPropertyForType(optionType);
112+
113+
// For `test` and `watch` namespaces, remove the namespace prefix
114+
// from keys to avoid redundancy (e.g., `test-concurrency` -> `concurrency`)
115+
// Also add the prefixed version as an alias for backward compatibility
116+
if (namespace === 'test' && keyWithoutPrefix.startsWith('test-')) {
117+
keyWithoutPrefix = StringPrototypeReplace(keyWithoutPrefix, 'test-', '');
118+
// Add alias: both `concurrency` and `test-concurrency` are valid
119+
namespaceProperties[originalKey] = propertySchema;
120+
namespaceProperties[keyWithoutPrefix] = propertySchema;
121+
} else if (namespace === 'watch' && keyWithoutPrefix.startsWith('watch-')) {
122+
keyWithoutPrefix = StringPrototypeReplace(keyWithoutPrefix, 'watch-', '');
123+
// Add alias: both `path` and `watch-path` are valid
124+
namespaceProperties[originalKey] = propertySchema;
125+
namespaceProperties[keyWithoutPrefix] = propertySchema;
126+
} else {
127+
// For other namespaces or keys without prefix, add normally
128+
namespaceProperties[keyWithoutPrefix] = propertySchema;
129+
}
111130
}
112131

113132
// Sort the namespace properties alphabetically
@@ -116,17 +135,6 @@ function generateConfigJsonSchema() {
116135
ArrayPrototypeMap(sortedNamespaceKeys, (key) => [key, namespaceProperties[key]]),
117136
);
118137
rootProperties[namespace].properties = sortedNamespaceProperties;
119-
120-
// For `test` and `watch` namespaces, avoid duplicating their options
121-
// under `nodeOptions`. These namespaces already have dedicated sections
122-
// at the root level.
123-
if (namespace === 'test' || namespace === 'watch') {
124-
for (const key of sortedNamespaceKeys) {
125-
if (key in nodeOptions) {
126-
delete nodeOptions[key];
127-
}
128-
}
129-
}
130138
}
131139

132140
// Sort the top-level properties by key alphabetically

0 commit comments

Comments
 (0)