Merge pull request #115 from clarkbw/bad-require

add console.error message to a bad require in a boot script
This commit is contained in:
Miroslav Bajtoš 2015-04-14 19:02:06 +02:00
commit 80831cdaaf
1 changed files with 12 additions and 7 deletions

View File

@ -231,13 +231,18 @@ function runScripts(app, list, callback) {
var functions = [];
list.forEach(function(filepath) {
debug('Requiring script %s', filepath);
var exports = require(filepath);
if (typeof exports === 'function') {
debug('Exported function detected %s', filepath);
functions.push({
path: filepath,
func: exports
});
try {
var exports = require(filepath);
if (typeof exports === 'function') {
debug('Exported function detected %s', filepath);
functions.push({
path: filepath,
func: exports
});
}
} catch (err) {
console.error('Failed loading boot script: %s\n%s', filepath, err.stack);
throw err;
}
});