config
config copied to clipboard
Support alternate parsers
Is there an existing issue that is already proposing this?
- [X] I have searched the existing issues
Is your feature request related to a problem? Please describe it
Currently the default parser, dotenv, fails to correctly parse my config file. In particular, it does not support parsing escaped JSON (see https://github.com/motdotla/dotenv/issues/771).
I'm using projen to create the file, which uses the ini library to do so. However, the output files that it creates are not always directly compatible with dotenv as a parser.
The ini parser also supports writing objects as section headers, and then supports parsing them back as well. This is potentially nice functionality to support as well.
Describe the solution you'd like
A new option on ConfigModuleOptions to specify the parser. The default would be the current dotenv parser, but the ini parser would be another option. If necessary, further parser options could be added in the future.
Alternatively, the config option could be the parser function itself. This would enable a BYO parser approach, and not require this library to add any extra dependencies
As far as I can tell, the variable expansion behavior can continue working as is using dotenv-expand without any issue.
Teachability, documentation, adoption, migration strategy
It should be relatively straightforward to add a section to the docs explaining the parser options, and reasons why the ini parser may be preferred over the dotenv parser.
What is the motivation / use case for changing the behavior?
See the problem section above.