Skip to content

Commit c90f36e

Browse files
authored
Update bootstrap-node.js to check for Array.isArray (microsoft#165289)
* Update bootstrap-node.js to check for Array.isArray * Update
1 parent 0c12170 commit c90f36e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/bootstrap-node.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,14 @@ exports.removeGlobalNodeModuleLookupPaths = function () {
7878
// @ts-ignore
7979
Module._resolveLookupPaths = function (moduleName, parent) {
8080
const paths = originalResolveLookupPaths(moduleName, parent);
81-
let commonSuffixLength = 0;
82-
while (commonSuffixLength < paths.length && paths[paths.length - 1 - commonSuffixLength] === globalPaths[globalPaths.length - 1 - commonSuffixLength]) {
83-
commonSuffixLength++;
81+
if (Array.isArray(paths)) {
82+
let commonSuffixLength = 0;
83+
while (commonSuffixLength < paths.length && paths[paths.length - 1 - commonSuffixLength] === globalPaths[globalPaths.length - 1 - commonSuffixLength]) {
84+
commonSuffixLength++;
85+
}
86+
return paths.slice(0, paths.length - commonSuffixLength);
8487
}
85-
return paths.slice(0, paths.length - commonSuffixLength);
88+
return paths;
8689
};
8790
};
8891

0 commit comments

Comments
 (0)