From 958432ca4aa575ff1dabccd028017891c3eddc3a Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 26 Sep 2014 13:19:23 -0400 Subject: [PATCH] closing julianlam/nodebb-plugin-sso-oauth#8 -- if a templates directory is defined without that directory being present, NodeBB will no longer crash --- src/plugins.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/plugins.js b/src/plugins.js index 412e66a3b4..90eacfbb83 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -591,9 +591,13 @@ var fs = require('fs'), if (plugin.templates && plugin.id && plugin.active) { var templatesPath = path.join(__dirname, '../node_modules', plugin.id, plugin.templates); utils.walk(templatesPath, function(err, pluginTemplates) { - pluginTemplates.forEach(function(pluginTemplate) { - templates["/" + pluginTemplate.replace(templatesPath, '').substring(1)] = pluginTemplate; - }); + if (pluginTemplates) { + pluginTemplates.forEach(function(pluginTemplate) { + templates["/" + pluginTemplate.replace(templatesPath, '').substring(1)] = pluginTemplate; + }); + } else { + winston.warn('[plugins/' + plugin.id + '] A templates directory was defined for this plugin, but was not found.'); + } next(err); });