Add custom --config option#163
Conversation
Codecov Report
@@ Coverage Diff @@
## master #163 +/- ##
===========================================
- Coverage 83.72% 38.26% -45.47%
===========================================
Files 7 7
Lines 338 345 +7
===========================================
- Hits 283 132 -151
- Misses 55 213 +158
Continue to review full report at Codecov.
|
lib/src/_utils.js
Outdated
| if (customFilename) { | ||
| return requireConfig(Path.join(path, customFilename)) || {}; | ||
| } else { | ||
| return getFileTypes() |
There was a problem hiding this comment.
What do you think about about:
return [].concat(customFilename, getFileTypes())
.reduce() || {};So that, if the user passes a wrong configuration file, gren will still look for existing ones.
There was a problem hiding this comment.
Good call! Since the user is passing a specific config filename in, they're expecting the file to exist — do you think it'd be more user-friendly to throw an error here and notify them that the file wasn't found?
There was a problem hiding this comment.
Definitely! I think we either check if other configuration files exist or we throw an error - as logging something in red in the console - which is still a good solution for me.
|
@all-contributors please add @kyeah for code |
|
I've put up a pull request to add @kyeah! 🎉 |
Closes #152.
Adds a
--configoption to specify a custom configuration file, e.g.Note that a plain grenrc file can only contain one
., so--custom=.custom.grenrcwill be parsed incorrectly (see the check here). I left it alone for now, but if you have a preference for how it should behave, let me know 👋