Skip to content

Commit

Permalink
module: fix regression in require ../
Browse files Browse the repository at this point in the history
Fixes regression in require system that prevented loading relative
packages via main property in package.json where the file is not
index.{ext}. The regression was introduced in commit 36777d2.

PR-URL: nodejs#145
Reviewed-By: Ben Noordhuis <[email protected]>
  • Loading branch information
Evan Lucas authored and bnoordhuis committed Dec 11, 2014
1 parent 0fbe528 commit 78a7dc2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ Module._findPath = function(request, paths) {
}
}

if (!filename) {
filename = tryPackage(basePath, exts);
}

if (!filename) {
// try it with each of the extensions at "index"
filename = tryExtensions(path.resolve(basePath, 'index'), exts);
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/require-bin/bin/req.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../');
1 change: 1 addition & 0 deletions test/fixtures/require-bin/lib/req.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = '';
4 changes: 4 additions & 0 deletions test/fixtures/require-bin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "req",
"main": "./lib/req.js"
}
4 changes: 4 additions & 0 deletions test/simple/test-require-extensions-main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
var common = require('../common');
var assert = require('assert');

require(common.fixturesDir + '/require-bin/bin/req.js');

0 comments on commit 78a7dc2

Please sign in to comment.