Skip to content

Commit

Permalink
Update internal Node.js function call
Browse files Browse the repository at this point in the history
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
  • Loading branch information
BridgeAR committed Apr 5, 2019
1 parent 86853a6 commit 2237087
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/requizzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ var path = require('path');
*/

function isNativeModule(targetPath, parentModule) {
var lookupPaths = Module._resolveLookupPaths(targetPath, parentModule);

if (lookupPaths[0] === targetPath && lookupPaths[1].length === 0) {
var lookupPaths = Module._resolveLookupPaths(targetPath, parentModule, true);
if (typeof lookupPaths === 'string')
return false;
if (lookupPaths === null)
return true;
}

return false;
return lookupPaths[0] === targetPath && lookupPaths[1].length === 0;
}

/**
Expand Down

0 comments on commit 2237087

Please sign in to comment.