add console.error message to a bad require in a boot script

This change produces the following error message in the tests:
`Failed loading boot script badScript.js`
`Cannot find module 'doesnt-exist’`
This commit is contained in:
Bryan Clark 2015-04-14 09:09:18 -07:00
parent 2e9f001100
commit 1d8bd15a77
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;
}
});