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: https://github.com/nodejs/node/pull/31933
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
Denys Otrishko authored and Rich Trott committed 2020-02-27 06:00:44 -08:00
1 parent 2ec9b58a41
commit 5c86475e20
1 file changed
+10 -1
+10 -1
View File
@@ -672,7 +672,7 @@ function invalidArgTypeHelper(input) {
return ` Received type ${typeof input} (${inspected})`;
}
module.exports = {
const common = {
allowGlobals,
buildType,
canCreateSymLink,
@@ -815,3 +815,12 @@ module.exports = {
}
};
const validProperties = new Set(Object.keys(common));
module.exports = new Proxy(common, {
get(obj, prop) {
if (!validProperties.has(prop))
throw new Error(`Using invalid common property: '${prop}'`);
return obj[prop];
}
});