Set app env if it is supplied in options object
Set the app env if it is supplied in options object which solves issue number 28 under loopback-boot repo
This commit is contained in:
parent
088ca864c2
commit
2574c9dbb6
|
@ -95,6 +95,7 @@ module.exports = function compile(options) {
|
|||
// loopback modifies the data. Since we are loading the data using `require`,
|
||||
// such change affects also code that calls `require` for the same file.
|
||||
var instructions = {
|
||||
env: env,
|
||||
config: appConfig,
|
||||
dataSources: dataSourcesConfig,
|
||||
models: modelInstructions,
|
||||
|
|
|
@ -23,6 +23,7 @@ module.exports = function execute(app, instructions, callback) {
|
|||
patchAppLoopback(app);
|
||||
assertLoopBackVersion(app);
|
||||
|
||||
setEnv(app, instructions);
|
||||
setHost(app, instructions);
|
||||
setPort(app, instructions);
|
||||
setApiRoot(app, instructions);
|
||||
|
@ -87,6 +88,12 @@ function assertLoopBackVersion(app) {
|
|||
}
|
||||
}
|
||||
|
||||
function setEnv(app, instructions) {
|
||||
var env = instructions.env;
|
||||
if (env !== undefined)
|
||||
app.set('env', env);
|
||||
}
|
||||
|
||||
function setHost(app, instructions) {
|
||||
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||
var host =
|
||||
|
|
|
@ -362,6 +362,11 @@ describe('executor', function() {
|
|||
}));
|
||||
}
|
||||
|
||||
it('should apply env passed in option object', function() {
|
||||
boot.execute(app, someInstructions({ env: 'custom_env' }));
|
||||
expect(app.get('env')).to.equal('custom_env');
|
||||
});
|
||||
|
||||
it('should honor host and port', function() {
|
||||
function assertHonored(portKey, hostKey) {
|
||||
process.env[hostKey] = randomPort();
|
||||
|
@ -854,6 +859,9 @@ function someInstructions(values) {
|
|||
}
|
||||
};
|
||||
|
||||
if (values.env)
|
||||
result.env = values.env;
|
||||
|
||||
if (values.files) {
|
||||
for (var k in values.files)
|
||||
result.files[k] = values.files[k];
|
||||
|
|
Loading…
Reference in New Issue