custom-env icon indicating copy to clipboard operation
custom-env copied to clipboard

An option to not output warnings to the console

Open deanWombourne opened this issue 3 years ago • 4 comments

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?

deanWombourne avatar Apr 01 '22 10:04 deanWombourne

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!

erisanolasheni avatar Apr 14 '22 17:04 erisanolasheni

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.

deanWombourne avatar Apr 14 '22 20:04 deanWombourne

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.

erisanolasheni avatar Apr 14 '22 21:04 erisanolasheni

@deanWombourne any update on this?

erisanolasheni avatar Apr 24 '23 11:04 erisanolasheni