Skip to content
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

Permit .json and .ini suffixes on config files #82

Open
Ghnuberath opened this issue Apr 29, 2016 · 5 comments
Open

Permit .json and .ini suffixes on config files #82

Ghnuberath opened this issue Apr 29, 2016 · 5 comments

Comments

@Ghnuberath
Copy link

Ghnuberath commented Apr 29, 2016

rc is awesome!

It's a tiny thing, but it would be great if the config file logic would permit .json and .ini extensions. In other words, looking for .${appname}rc, .${appname}rc.json or .${appname}rc.ini in all the usual places.

Definitely helps with triggering syntax highlighting in your editor of choice.

This idea was mentioned in #71, but since the scope of this feature request is far smaller in scope, I've opened it as a separate issue.

@nikolay
Copy link

nikolay commented Jul 12, 2016

It would be nice if YAML is supported as well - just like with .eslintrc!

@dominictarr
Copy link
Owner

I think file extentions is reasonable. I do not want to add yaml, but you can already use a custom parser (see the docs) already.

Currently, rc will attempt to parse .{appname}rc as both ini and json but if we have a .json file in ini format should be an error, obviously.

Perhaps the way to do this would be to put an object {ini: INI.parse, json: JSON.parse, yml: YAML.parse} in the place of the custom parser, and that will try exactly those extentions, with those parsers. Then you can have yaml. If you want only one parser (which is reasonable) then use only one.

Looking back I think that parsing one file as a variety of formats was a mistake. And the worst part, is I don't even know how many people are using ini! but I would if you had to explicitly set it, because I'd be able to look at the code of modules that depend on rc. principle 2. explicit is better than implicit

@dominictarr
Copy link
Owner

if you want to have backwards support for a default parser, use empty string as a key: {"": function (str) { try { return JSON.parse(str) } catch (_) { return INI.parse(str) } }}

(we'd have to handle that case specially, without adding the . but that would give us backwards compat.

legodude17 added a commit to legodude17/rc that referenced this issue Aug 14, 2016
This adds support for the file extensions and for parsers
by specific extension. All tests pass and a new one was
added to test the extensions.
@legodude17
Copy link

I made a pull request for the solution you were talking about @dominictarr, #85.

@jrop
Copy link

jrop commented Jun 1, 2017

Since this has appeared inactive, I have rewritten this module from the ground up as my own rc2. The loaders are fully configurable, and asynchronous. I plan on maintaining this module and reviewing PRs as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants