mirror of https://github.com/nodejs/node.git
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
parent
7067a7155f
commit
d75b63bc3c
|
@ -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;
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
exports.foo = "ok"
|
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue