Skip to content

Commit 348d9e9

Browse files
committed
Update internal Node.js function call
This updates the call to _resolveLookupPaths. It returns a string by default since Node.js v8 when called with a third truthy argument. The backwards compatible return value should change soon, so detect what return type is used and handle both cases. Refs: nodejs/node#26983
1 parent 86853a6 commit 348d9e9

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

lib/requizzle.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@ var path = require('path');
4040
*/
4141

4242
function isNativeModule(targetPath, parentModule) {
43-
var lookupPaths = Module._resolveLookupPaths(targetPath, parentModule);
44-
45-
if (lookupPaths[0] === targetPath && lookupPaths[1].length === 0) {
46-
return true;
47-
}
48-
49-
return false;
43+
var lookupPaths = Module._resolveLookupPaths(targetPath, parentModule, true);
44+
/* istanbul ignore next */
45+
return lookupPaths === null ||
46+
lookupPaths.length === 2 &&
47+
lookupPaths[1].length === 0 &&
48+
lookupPaths[0] === targetPath;
5049
}
5150

5251
/**

0 commit comments

Comments
 (0)