From dff810f31c6d9b3dfbcc2300e127d132760a7c46 Mon Sep 17 00:00:00 2001 From: Ritchie Date: Mon, 17 Jun 2013 08:23:41 -0700 Subject: [PATCH] Filter out non js files from middleware loader --- lib/asteroid.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/asteroid.js b/lib/asteroid.js index e0d19243..67498417 100644 --- a/lib/asteroid.js +++ b/lib/asteroid.js @@ -63,9 +63,14 @@ for (var key in express) { * for example `asteroid.configure` etc. */ -fs.readdirSync(path.join(__dirname, 'middleware')).forEach(function (m) { - asteroid[m.replace(/\.js$/, '')] = require('./middleware/' + m); -}); +fs + .readdirSync(path.join(__dirname, 'middleware')) + .filter(function (file) { + return file.match(/\.js$/); + }) + .forEach(function (m) { + asteroid[m.replace(/\.js$/, '')] = require('./middleware/' + m); + }); /** * Error handler title