-
Notifications
You must be signed in to change notification settings - Fork 97
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
Changes 'config' key to point to latest parsed config file instead of only $PWD/.namerc if it exists #34
Conversation
… only $PWD/.slaprc if it exists
home ? cc.json(join(home, '.' + name, 'config')) : {}, | ||
home ? cc.json(join(home, '.' + name + 'rc')) : {}, | ||
cc.json(local), | ||
local ? {config: local} : null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the config key in question.
Hey @dominictarr, could you take a look at this PR? Thanks for making such a useful library! |
sorry I missed this. I do not merge pull requests that do not explain their context. There are a lot of people that use this, |
@dominictarr sure! In the current iteration of rc, if I am using this in slap to detect whether a user configuration file exists. If it does not exist, it displays a first-run message, and creates the file. |
ah, okay this solves a problem similar to #33 @achingbrain @mikermcneil what do you think about this approach. It's quite simple, not a breaking change, and looks like it solves the problem too. |
Looks like it would only report the last config file loaded. E.g. if I were to do: $ config=/path/to/fileA node foo.js --config=/path/to/fileB only It would be better to report all loaded files rather than just the last one because the options in the files are merged not overwritten. It also overwrites the |
@achingbrain the current version of P.S. I agree that it would probably be better to report all loaded files rather than the last one. I wrote it this way to stay as backwards-compatible as possible. I'll be happy to change the PR if we can agree to change the |
@dominictarr what do you think? |
@secrettriangle hmm, I'm thinking that overwriting a --config option with an array is surprising. it would be okay if Maybe there are some situations where you really do want full array... but I'd rather leave that feature until some one actually needs it, rather than try to guess it. Oh, just realized that was what @achingbrain has, |
@dominictarr Yes, pretty much every time. The use case is: ship a config file with your app that contains all the options fully documented, then the user can override a subset of those options in a second config file. |
FWIW I agree, swapping a string for an array seems a bit odd, that's why my PR added a method to return the array of loaded config file paths instead of overwriting existing keys. |
@achingbrain okay this is interesting. |
I've rebased this PR and added the |
@achingbrain can I hear your side of the story on how you do defaults and files? else I will merge @secrettriangle's pr: #44 |
The |
@achingbrain that is an interesting point, though that would probably be a breaking change and it would be pretty hard to tell what it would break. It's another discussion, anyway. |
No description provided.