Permalink
Browse files

Fixed error when .svn-files are included in controller directory

  • Loading branch information...
1 parent 626f7fd commit 6761103c8de3abc3da4db6b9b182226721268ab8 @JulianDuniec committed Oct 11, 2012
@@ -13,7 +13,10 @@ module.exports = {
fs.readdir(me.directory, function(err, list) {
list.forEach(function(file) {
- var controller = require(me.directory + '/' + file);
+ var fileName = me.directory + '/' + file;
+ if(fileName.indexOf('Controller') == -1)
+ return;
+ var controller = require(fileName);
for(var key in controller) {
//The function in the controller
var f = controller[key];
@@ -31,9 +34,10 @@ module.exports = {
//Binds the route in the app to the method
me.bindFunction(app, path, params, f);
}
+ if(cb)
+ cb();
});
- if(cb)
- cb();
+
});
},
View
@@ -1,6 +1,6 @@
{
"name": "express-controller",
- "version": "0.1.2",
+ "version": "0.1.3",
"dependencies": {
"nodeunit" : "*"
},
@@ -80,5 +80,19 @@ module.exports = {
expressControllers.bind(app, function() {
test.done();
});
- }
+ },
+
+ ignoreInvalidFiles : function(test) {
+ var controllersDir = __dirname + '/mock/ignoreInvalidFiles/';
+ expressControllers
+ .setDirectory(controllersDir);
+ var app = {
+ get : function(path, method) {
+ test.equal(path, '/valid');
+ }
+ };
+ expressControllers.bind(app, function() {
+ test.done();
+ })
+ }
}
@@ -0,0 +1,5 @@
+module.exports = {
+ get_index : function(req,res) {
+ res.send(200);
+ }
+};
No changes.

0 comments on commit 6761103

Please sign in to comment.