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 6, 2019
1 parent 86853a6 commit 348d9e9
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 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) {
return true;
}

return false;
var lookupPaths = Module._resolveLookupPaths(targetPath, parentModule, true);
/* istanbul ignore next */
return lookupPaths === null ||
lookupPaths.length === 2 &&
lookupPaths[1].length === 0 &&
lookupPaths[0] === targetPath;
}

/**
Expand Down

0 comments on commit 348d9e9

Please sign in to comment.