Skip to content

Commit 67c3a95

Browse files
lundibundicodebytere
authored andcommitted
test: validate common property usage
`common` contains multiple 'check'(boolean) properties that will be false if mistyped and may lead to errors. This makes sure that the used property exists in the `common`. PR-URL: #31933 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Shelley Vohr <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 26d9f4c commit 67c3a95

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

test/common/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ function invalidArgTypeHelper(input) {
739739
return ` Received type ${typeof input} (${inspected})`;
740740
}
741741

742-
module.exports = {
742+
const common = {
743743
allowGlobals,
744744
buildType,
745745
canCreateSymLink,
@@ -882,3 +882,12 @@ module.exports = {
882882
}
883883

884884
};
885+
886+
const validProperties = new Set(Object.keys(common));
887+
module.exports = new Proxy(common, {
888+
get(obj, prop) {
889+
if (!validProperties.has(prop))
890+
throw new Error(`Using invalid common property: '${prop}'`);
891+
return obj[prop];
892+
}
893+
});

0 commit comments

Comments
 (0)