From c8384dca8cc07c6357bdd8075dc11f95ef42c1d6 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sat, 6 Apr 2019 01:04:02 +0200 Subject: [PATCH] chore: 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. --- src/util.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/util.js b/src/util.js index 9514323..1632331 100644 --- a/src/util.js +++ b/src/util.js @@ -98,8 +98,10 @@ function packageNameFromPath(path) { */ function findModulePath(request, parent) { var mainScriptDir = path.dirname(Module._resolveFilename(request, parent)); - var resolvedModule = Module._resolveLookupPaths(request, parent); - var paths = resolvedModule[1]; + var resolvedModule = Module._resolveLookupPaths(request, parent, true); + var paths = typeof resolvedModule === 'string' || resolvedModule === null ? + resolvedModule : + resolvedModule[1]; for (var i = 0, PL = paths.length; i < PL; i++) { if (mainScriptDir.indexOf(paths[i]) === 0) { return path.join(paths[i], request.replace('/', path.sep));