mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
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.
This commit is contained in:
parent
7067a7155f
commit
d75b63bc3c
3 changed files with 7 additions and 1 deletions
|
@ -142,7 +142,8 @@ function findModulePath (id, dirs, callback) {
|
||||||
path.join(dir, id + ".js"),
|
path.join(dir, id + ".js"),
|
||||||
path.join(dir, id + ".node"),
|
path.join(dir, id + ".node"),
|
||||||
path.join(dir, id, "index.js"),
|
path.join(dir, id, "index.js"),
|
||||||
path.join(dir, id, "index.node")
|
path.join(dir, id, "index.node"),
|
||||||
|
path.join(dir, id)
|
||||||
];
|
];
|
||||||
|
|
||||||
var ext;
|
var ext;
|
||||||
|
|
2
test/fixtures/foo
vendored
Normal file
2
test/fixtures/foo
vendored
Normal file
|
@ -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");
|
var foo = require("../fixtures/require-path/p1/foo");
|
||||||
process.assert(foo.bar.expect === foo.bar.actual);
|
process.assert(foo.bar.expect === foo.bar.actual);
|
||||||
|
|
||||||
|
assert.equal(require('../fixtures/foo').foo, 'ok',
|
||||||
|
'require module with no extension');
|
||||||
|
|
||||||
process.addListener("exit", function () {
|
process.addListener("exit", function () {
|
||||||
assert.equal(true, a.A instanceof Function);
|
assert.equal(true, a.A instanceof Function);
|
||||||
assert.equal("A done", a.A());
|
assert.equal("A done", a.A());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue