Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup: notes from review
  • Loading branch information
MylesBorins committed Apr 30, 2019
commit 9ec4cb8d607945be44ddf7647382b0d40cbf3db4
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') :
Comment thread
guybedford marked this conversation as resolved.
Outdated
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