-
Notifications
You must be signed in to change notification settings - Fork 488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling setModuleDefaults
on empty module causes an error
#578
Comments
The current behavior helps catch typos when you typed As alternate resolution, what about creating Changing the behavior may address your desire but cause silent failure for someone else who expected |
I can understand that. In some file formats, that's just not always the clearest. For example in yaml,
still resolves to undefined. You can do
but then you start mixing json and yaml which feels a little weird and might be prone to be deleted or missed by a dev who would be somewhat confused why that is there. It'd be nice to not have to include that in every app that will use my library to set it's configs, but maybe that's necessary. |
this bothers me either, now I have to tell everyone using my library to add an empty config in their project, instead of relying on the default behavior |
Does this still happen? I am working on some new code that will use |
Note: for support questions, please use StackOverflow and tag your question with
node-config
. This repository's issues are reserved for feature requests and bug reports.Before submitting a bug report, please search the issue tracker the wiki first. Many issues have already been discussed.
The wiki is located at: https://github.com/lorenwest/node-config/wiki
I'm submitting a ...
What is the current behavior?
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem:
If you have a config that does not include in a module, calling
setModuleDefaults
for that module causes an error.For example if my config resolves to the following object:
and I call
config.util.setModuleDefault('module2', {a: "value"})
, I will get acannot read property 'module2' of undefined
error.What is the expected behavior?
I would expect that if the module does not exist, the module should be added to the config.
Please tell us about your environment:
Other information
The problem appears to be related to
getImpl
returning undefined for the module, which might be the right behavior for that function, but then that undefined value is passed into extendDeep. Perhaps if the result ofgetImpl
isundefined
ornull
, an empty object should be passed intoextendDeep
.The text was updated successfully, but these errors were encountered: