module: fix regression in require ../

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: https://github.com/iojs/io.js/pull/145
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
Evan Lucas 2014-12-11 01:37:03 -06:00 committed by Ben Noordhuis
parent 0fbe528243
commit 78a7dc2b8f
5 changed files with 14 additions and 0 deletions

View File

@ -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);

1
test/fixtures/require-bin/bin/req.js vendored Normal file
View File

@ -0,0 +1 @@
module.exports = require('../');

1
test/fixtures/require-bin/lib/req.js vendored Normal file
View File

@ -0,0 +1 @@
module.exports = '';

View File

@ -0,0 +1,4 @@
{
"name": "req",
"main": "./lib/req.js"
}

View File

@ -0,0 +1,4 @@
var common = require('../common');
var assert = require('assert');
require(common.fixturesDir + '/require-bin/bin/req.js');