diff options
author | Nick Stenning <nick@whiteink.com> | 2010-08-04 21:45:52 +0100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-08-04 15:55:47 -0700 |
commit | 78520ba4823f88aa17c4da9e5da00fc913269de9 (patch) | |
tree | a4249ada8a1183744d64020fda07d8ff2825e717 /test | |
parent | 0b925d075d359d03426f0b32bb58a5e05825b4ea (diff) | |
download | node-new-78520ba4823f88aa17c4da9e5da00fc913269de9.tar.gz |
Don't attempt to load a directory.
This patch replaces the path.exists check for module loading with a call to
fs.statSync (or fs.stat for require.async) which ensures that it's not trying
to load a directory.
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/empty/.gitkeep | 0 | ||||
-rw-r--r-- | test/simple/test-module-loading.js | 19 |
2 files changed, 19 insertions, 0 deletions
diff --git a/test/fixtures/empty/.gitkeep b/test/fixtures/empty/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/fixtures/empty/.gitkeep diff --git a/test/simple/test-module-loading.js b/test/simple/test-module-loading.js index 5245e4ea0f..7405c0887f 100644 --- a/test/simple/test-module-loading.js +++ b/test/simple/test-module-loading.js @@ -106,6 +106,23 @@ process.assert(foo.bar.expect === foo.bar.actual); assert.equal(require('../fixtures/foo').foo, 'ok', 'require module with no extension'); +// Should not attempt to load a directory +try { + require("../fixtures/empty"); +} catch(err) { + assert.equal(err.message, "Cannot find module '../fixtures/empty'"); +} + +var asyncRequireDir = false; +require.async("../fixtures/empty", function (err, a) { + assert.ok(err); + + if (err) { + asyncRequireDir = true; + assert.equal(err.message, "Cannot find module '../fixtures/empty'"); + } +}); + process.addListener("exit", function () { assert.equal(true, a.A instanceof Function); assert.equal("A done", a.A()); @@ -128,5 +145,7 @@ process.addListener("exit", function () { assert.equal(true, errorThrownAsync); + assert.equal(true, asyncRequireDir); + console.log("exit"); }); |