dominictarr / rc

The non-configurable configuration loader for lazy people.
Other
1.02k stars 97 forks source link

Support custom filepaths #71

Open AndersDJohnson opened 8 years ago

AndersDJohnson commented 8 years ago

Maybe accept a filepaths array instead of the first argument, e.g. rc(['./my/custom/path'])? Then also expose default paths as rc.paths(appname) (as function not array, for immutability), so that user can prepend/append/inject custom paths in their preferred order, e.g. rc(['./custom/path'].concat(rc.paths(appname)))?

I might be able to submit a PR if you'd be interested.

dominictarr commented 8 years ago

As it stands, I'm not interested in a change like that. I am willing to listen to people who want to make changes to rc but I set a high bar for changes, and expect a solid justification of why that feature would be useful, in the context of a real application. This approach has meant that rc has remained focused and simple.

The goal of rc is to make it so that if you understand rc you never need to read custom configuration loading code.

So, tell me about your application and how it would use this feature and why it needs it. This is the important part, code is easy.

AndersDJohnson commented 8 years ago

@dominictarr Fair enough, maybe it doesn't make sense for this project.

I might want to append a .json or .ini suffix to the file names for better support in other programs or tools.

I might want to load different configuration file names from disk - e.g. for different deployment environments like .appnamerc-dev vs. .appnamerc-prod. A similar effect could be accomplished with command-line arguments or environment variables, but this is a different use case.

AndersDJohnson commented 8 years ago

Also, if I wanted to migrate a project to use rc, but needed backwards compatibility with previous config file names, e.g. for the node-gh project, which currently expects ~/.gh.json file.