Skip to content

Commit

Permalink
fixup: notes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
MylesBorins committed Apr 30, 2019
1 parent 5942747 commit 9ec4cb8
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') :
Expand All @@ -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);
};

Expand Down

0 comments on commit 9ec4cb8

Please sign in to comment.