From 9658f76e5f54aa490a76fab21b5c3ea2a4efbf61 Mon Sep 17 00:00:00 2001 From: Jake Swanson Date: Thu, 30 Jan 2014 15:12:18 -0500 Subject: [PATCH] stop trying to require non-js/hidden files editors like VIM place hidden files for recovery/etc in certain cases. this changes the model bootstrap to only require .js files, to avoid that case. also thought about only requiring non-hidden files (`!match(/^\./)`), but thought this was more correct. --- templates/express/server.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/express/server.js b/templates/express/server.js index 6da04b76e..c0c258969 100644 --- a/templates/express/server.js +++ b/templates/express/server.js @@ -21,6 +21,7 @@ var db = mongoose.connect(config.mongo.uri, config.mongo.options); // Bootstrap models var modelsPath = path.join(__dirname, 'lib/models'); fs.readdirSync(modelsPath).forEach(function (file) { + if (!file.match(/\.js$/)) return; // only .js files require(modelsPath + '/' + file); }); @@ -44,4 +45,4 @@ app.listen(config.port, function () { }); // Expose app -exports = module.exports = app; \ No newline at end of file +exports = module.exports = app;