From 9ec4cb8d607945be44ddf7647382b0d40cbf3db4 Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Tue, 30 Apr 2019 10:48:22 -0700 Subject: [PATCH] fixup: notes from review --- lib/internal/modules/cjs/loader.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 3fe092cc8d9994..5df34cb3f022b4 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -826,9 +826,8 @@ Module.runMain = function() { Module.createRequireFromPath = (filename) => { // Allow a directory to be passed as the filename - const normalized = path.win32.normalize(filename); - const trailingSlash = normalized.charCodeAt(normalized.length - 1) === - CHAR_BACKWARD_SLASH; + const trailingSlash = + filename.endsWith(path.sep) || path.sep !== '/' && filename.endsWith('\\'); const proxyPath = trailingSlash ? path.join(filename, 'noop.js') : @@ -837,7 +836,7 @@ Module.createRequireFromPath = (filename) => { const m = new Module(proxyPath); m.filename = proxyPath; - m.paths = Module._nodeModulePaths(path.dirname(proxyPath)); + m.paths = Module._nodeModulePaths(m.path); return makeRequireFunction(m); };