An option to not output warnings to the console
Hi,
I'm using custom-env version 2.0.1.
When running tests I get console warnings like:
console.warn
No env file present for the current environment: test
Falling back to .env config
This is because I just have a .env file, and no explicit .env.test version (and no real desire to just duplicate these values in two places!)
Is there a way to hide these warnings?
i.e. like this maybe
require('custom-env').quiet().env();
or maybe as a configuration option (though, without named options this gets ugly pretty quickly!)
require(`custom-env`).env(true, null, true, true); // 4th argument would be quiet or not.
Another option might be to somehow provide a custom logger which would default to console?
require('custom-env').logger(MyLogger).env();
Happy to go with whichever option fits your style, and I can have a poke at a pull request if you like?
This is a great idea, I will be looking at this in my free time, however, @deanWombourne this is why we have it as open-source! If you need it quickly, you can make a PR and I will happily merge this.
Thanks!
I can certainly try! Any preference on what you'd like it to look like at the call site (i.e. require('custom-env')._something_) ? I don't have much experience, so happy to go in whichever direction you suggest.
Thanks, require('custom-env').quiet().env(); and require('custom-env').env(true, null, true, true); is preferred, but in the case the first one should be require('custom-env').env().quiet();
Thanks.
@deanWombourne any update on this?