sails-util-mvcsloader icon indicating copy to clipboard operation
sails-util-mvcsloader copied to clipboard

feature request: load environment config

Open tswaters opened this issue 10 years ago • 3 comments

Right now any environment-specific config under ./config/env is not being loaded.

There's a few additional things that sails will attempt to load - including local.js, env/{env}/*.js, and env/{env}.js -- this logic is not coming through with the loader.

The code in sails core that handles this is here: https://github.com/balderdashy/sails/blob/master/lib/hooks/moduleloader/index.js#L223-L236

As best as I can determine, buildDictionary isn't actually asynchronous so it should be a matter of of updating ./libs/config to include the same logic as sails core.

PR incoming.

tswaters avatar Oct 05 '15 23:10 tswaters

Great idea to load more config options but as I can think now, load the config in async will break this loader, cause we want to load config before any hook initialisations, if you make it async sails can launch some hook initialisation before config is load... @leeroybrun did you make some test to be sure it's ok about this ?

jaumard avatar Oct 07 '15 07:10 jaumard

My fault, I think you are right @jaumard. I've not thinked about the sync/async problem with config.

We need to do more tests on this...

leeroybrun avatar Oct 07 '15 07:10 leeroybrun

There is definitely a race condition here... I didn't realize that async.auto wraps task completions in setImmediate.

Fortunately, sails-build-dictionary is synchronous, so it shouldn't be too hard to rework this to be completely synchronous.... I'll send a new PR with this.

tswaters avatar Nov 07 '15 03:11 tswaters