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`,
|
// loopback modifies the data. Since we are loading the data using `require`,
|
||||||
// such change affects also code that calls `require` for the same file.
|
// such change affects also code that calls `require` for the same file.
|
||||||
var instructions = {
|
var instructions = {
|
||||||
|
env: env,
|
||||||
config: appConfig,
|
config: appConfig,
|
||||||
dataSources: dataSourcesConfig,
|
dataSources: dataSourcesConfig,
|
||||||
models: modelInstructions,
|
models: modelInstructions,
|
||||||
|
|
|
@ -23,6 +23,7 @@ module.exports = function execute(app, instructions, callback) {
|
||||||
patchAppLoopback(app);
|
patchAppLoopback(app);
|
||||||
assertLoopBackVersion(app);
|
assertLoopBackVersion(app);
|
||||||
|
|
||||||
|
setEnv(app, instructions);
|
||||||
setHost(app, instructions);
|
setHost(app, instructions);
|
||||||
setPort(app, instructions);
|
setPort(app, instructions);
|
||||||
setApiRoot(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) {
|
function setHost(app, instructions) {
|
||||||
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
var host =
|
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() {
|
it('should honor host and port', function() {
|
||||||
function assertHonored(portKey, hostKey) {
|
function assertHonored(portKey, hostKey) {
|
||||||
process.env[hostKey] = randomPort();
|
process.env[hostKey] = randomPort();
|
||||||
|
@ -854,6 +859,9 @@ function someInstructions(values) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (values.env)
|
||||||
|
result.env = values.env;
|
||||||
|
|
||||||
if (values.files) {
|
if (values.files) {
|
||||||
for (var k in values.files)
|
for (var k in values.files)
|
||||||
result.files[k] = values.files[k];
|
result.files[k] = values.files[k];
|
||||||
|
|
Loading…
Reference in New Issue