Support including modules that don't have an extension.

This way, require("/foo") will work if there is a "foo.js", or a file named
simply "foo" with no extension.
v0.7.4-release
isaacs 2010-07-19 17:54:49 -07:00 committed by Ryan Dahl
parent 7067a7155f
commit d75b63bc3c
3 changed files with 7 additions and 1 deletions

View File

@ -142,7 +142,8 @@ function findModulePath (id, dirs, callback) {
path.join(dir, id + ".js"),
path.join(dir, id + ".node"),
path.join(dir, id, "index.js"),
path.join(dir, id, "index.node")
path.join(dir, id, "index.node"),
path.join(dir, id)
];
var ext;

2
test/fixtures/foo vendored 100644
View File

@ -0,0 +1,2 @@
exports.foo = "ok"

View File

@ -103,6 +103,9 @@ debug("load modules by absolute id, then change require.paths, and load another
var foo = require("../fixtures/require-path/p1/foo");
process.assert(foo.bar.expect === foo.bar.actual);
assert.equal(require('../fixtures/foo').foo, 'ok',
'require module with no extension');
process.addListener("exit", function () {
assert.equal(true, a.A instanceof Function);
assert.equal("A done", a.A());