diff --git a/index.js b/index.js index 240c574..6e6bdf6 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,7 @@ var path = require('path'); var _ = require('underscore'); var loopback = require('loopback'); var ConfigLoader = require('./lib/config-loader'); +var debug = require('debug')('loopback-boot'); /** * Initialize an application from an options object or @@ -287,6 +288,10 @@ function tryRequire(modulePath) { try { return require.apply(this, arguments); } catch(e) { + if(e.code === 'MODULE_NOT_FOUND') { + debug('Warning: cannot require %s - module not found.', modulePath); + return undefined; + } console.error('failed to require "%s"', modulePath); throw e; } diff --git a/package.json b/package.json index f7eb437..8c614f1 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,8 @@ "url": "https://github.com/strongloop/loopback-boot/blob/master/LICENSE" }, "dependencies": { - "underscore": "^1.6.0" + "underscore": "^1.6.0", + "debug": "^0.8.1" }, "devDependencies": { "loopback": "^1.5.0", diff --git a/test/boot.test.js b/test/boot.test.js index 947d45b..6ebdcc8 100644 --- a/test/boot.test.js +++ b/test/boot.test.js @@ -379,6 +379,17 @@ describe('bootLoopBackApp', function() { boot(app, appDir); expect(global.fnCalled, 'exported fn was called').to.be.undefined(); }); + + it('supports models/ subdirectires that are not require()able', function() { + givenAppInSandbox(); + writeAppFile('models/test/model.test.js', + 'throw new Error("should not been called");'); + + var app = loopback(); + boot(app, appDir); + + // no assert, the test passed when we got here + }); }); });