Update bootstrap-node.js to check for Array.isArray (#165289)

* Update bootstrap-node.js to check for Array.isArray

* Update
This commit is contained in:
Mark Zuber
2022-11-07 01:07:28 -08:00
committed by GitHub
parent 0c121703bb
commit c90f36e95b

11
src/bootstrap-node.js vendored
View File

@@ -78,11 +78,14 @@ exports.removeGlobalNodeModuleLookupPaths = function () {
// @ts-ignore
Module._resolveLookupPaths = function (moduleName, parent) {
const paths = originalResolveLookupPaths(moduleName, parent);
let commonSuffixLength = 0;
while (commonSuffixLength < paths.length && paths[paths.length - 1 - commonSuffixLength] === globalPaths[globalPaths.length - 1 - commonSuffixLength]) {
commonSuffixLength++;
if (Array.isArray(paths)) {
let commonSuffixLength = 0;
while (commonSuffixLength < paths.length && paths[paths.length - 1 - commonSuffixLength] === globalPaths[globalPaths.length - 1 - commonSuffixLength]) {
commonSuffixLength++;
}
return paths.slice(0, paths.length - commonSuffixLength);
}
return paths.slice(0, paths.length - commonSuffixLength);
return paths;
};
};