diff --git a/lib/compiler.js b/lib/compiler.js index dc08f6e..ef9aecc 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -71,6 +71,8 @@ module.exports = function compile(options) { bootDirs.forEach(function(dir) { bootScripts = bootScripts.concat(findScripts(dir)); + var envdir = dir + '/' + env; + bootScripts = bootScripts.concat(findScripts(envdir)); }); // de-dedup boot scripts -ERS diff --git a/test/executor.test.js b/test/executor.test.js index f826a1f..b1680e7 100644 --- a/test/executor.test.js +++ b/test/executor.test.js @@ -11,6 +11,7 @@ var supertest = require('supertest'); var os = require('os'); var SIMPLE_APP = path.join(__dirname, 'fixtures', 'simple-app'); +var ENV_APP = path.join(__dirname, 'fixtures', 'env-app'); var app; @@ -754,6 +755,19 @@ describe('executor', function() { .get('/') .expect('passport', 'initialized', done); }); + + describe('when booting with env', function() { + it('should set the `booting` flag during execution', function(done) { + expect(app.booting).to.be.undefined(); + boot.execute(app, envAppInstructions(), function(err) { + if (err) return done(err); + expect(app.booting).to.be.false(); + expect(process.bootFlags).to.not.have.property('barLoadedInTest'); + done(); + }); + }); + }); + }); function simpleMiddlewareConfig(phase, params) { @@ -826,3 +840,11 @@ function simpleAppInstructions() { fs.copySync(SIMPLE_APP, appdir.PATH); return boot.compile(appdir.PATH); } + +function envAppInstructions() { + fs.copySync(ENV_APP, appdir.PATH); + return boot.compile({ + appRootDir: appdir.PATH, + env: 'test' + }); +} diff --git a/test/fixtures/env-app/boot/test/bar.js b/test/fixtures/env-app/boot/test/bar.js new file mode 100644 index 0000000..d2a1f2f --- /dev/null +++ b/test/fixtures/env-app/boot/test/bar.js @@ -0,0 +1,4 @@ +process.bootFlags.push('barLoadedInTest'); +module.exports = function(app, callback) { + callback(); +}; diff --git a/test/fixtures/env-app/config.json b/test/fixtures/env-app/config.json new file mode 100644 index 0000000..8358c75 --- /dev/null +++ b/test/fixtures/env-app/config.json @@ -0,0 +1,4 @@ +{ + "port": 3000, + "host": "127.0.0.1" +} diff --git a/test/fixtures/env-app/datasources.json b/test/fixtures/env-app/datasources.json new file mode 100644 index 0000000..05a18b3 --- /dev/null +++ b/test/fixtures/env-app/datasources.json @@ -0,0 +1,5 @@ +{ + "db": { + "connector": "memory" + } +} diff --git a/test/fixtures/env-app/model-config.json b/test/fixtures/env-app/model-config.json new file mode 100644 index 0000000..0468a66 --- /dev/null +++ b/test/fixtures/env-app/model-config.json @@ -0,0 +1,5 @@ +{ + "User": { + "dataSource": "db" + } +}