mirror of
https://github.com/nodejs/node-v0.x-archive.git
synced 2026-04-28 03:01:10 -04:00
package.json main as indexed subdir
Closes GH-686.
This commit is contained in:
@@ -85,7 +85,8 @@ function tryPackage(requestPath, exts) {
|
||||
if (!pkg || !pkg.main) return false;
|
||||
|
||||
var filename = path.resolve(requestPath, pkg.main);
|
||||
return tryFile(filename) || tryExtensions(filename, exts);
|
||||
return tryFile(filename) || tryExtensions(filename, exts) ||
|
||||
tryExtensions(path.resolve(filename, 'index'), exts);
|
||||
}
|
||||
|
||||
// In order to minimize unnecessary lstat() calls,
|
||||
|
||||
1
test/fixtures/packages/main-index/package-main-module/index.js
vendored
Normal file
1
test/fixtures/packages/main-index/package-main-module/index.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
exports.ok = "ok"
|
||||
3
test/fixtures/packages/main-index/package.json
vendored
Normal file
3
test/fixtures/packages/main-index/package.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{"name":"package-name"
|
||||
,"version":"1.2.3"
|
||||
,"main":"package-main-module"}
|
||||
@@ -70,6 +70,8 @@ assert.notEqual(threeFolder, three);
|
||||
common.debug('test package.json require() loading');
|
||||
assert.equal(require('../fixtures/packages/main').ok, 'ok',
|
||||
'Failed loading package');
|
||||
assert.equal(require('../fixtures/packages/main-index').ok, 'ok',
|
||||
'Failed loading package with index.js in main subdir');
|
||||
|
||||
common.debug('test cycles containing a .. path');
|
||||
var root = require('../fixtures/cycles/root'),
|
||||
|
||||
Reference in New Issue
Block a user