fixes #524 again

This commit is contained in:
Tobias Koppers 2014-11-02 12:16:55 +01:00
parent 9a375a770a
commit 6a8caf5cd1
2 changed files with 16 additions and 2 deletions

View File

@ -75,7 +75,7 @@ ContextModuleFactory.prototype.create = function(context, dependency, callback)
ContextModuleFactory.prototype.resolveDependencies = function resolveDependencies(fs, resource, recursive, regExp, callback) {
(function addDirectory(directory, callback) {
fs.readdir(directory, function(err, files) {
if(!files || files.length === 0) return callback();
if(!files || files.length === 0) return callback(null, []);
async.map(files, function(seqment, callback) {
var subResource = path.join(directory, seqment)

View File

@ -8,4 +8,18 @@ it("should support an empty context", function() {
c("");
}).should.throw();
c.keys().should.be.eql([]);
});
});
// This would be a useful testcase, but it requires an (really) empty directory.
// **but** you cannot commit empty directories into git
/*it("should support an empty context (empty dir)", function() {
var c = require.context("./empty", true, /^nothing$/);
c.id.should.be.type("number");
(function() {
c.resolve("");
}).should.throw();
(function() {
c("");
}).should.throw();
c.keys().should.be.eql([]);
});*/