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

feat(constructor): expose 'failSoftly' (=catch load error) option #87

Closed
wants to merge 2 commits into from

Conversation

cbrunnkvist
Copy link

@cbrunnkvist cbrunnkvist commented Oct 4, 2017

I need my build to fail in case opening the .env file fails. This patch adds an option failSoftly=true which keeps compatibility with current behavior but allows for any exception raised in .parse() to propagate when set to false.

@mrsteele
Copy link
Owner

mrsteele commented Oct 4, 2017

Thanks for the contribution @cbrunnkvist!

I'm trying to chew on this a bit because I'm wondering now if we should be forcing a failed parse all the time.

If the file doesn't exist, I think we should let that work as is, however a PARSE error is much different and perhaps we should be forwarding that.

What do you think about updating it to not have that configuration option but instead check for the type of error.

If the error is because the file is missing, do what currently happens in prod, if the error is a parsing error, throw that error as expected.

Thoughts?

@cbrunnkvist
Copy link
Author

Surprised to see CI failing, I was working for me...

Regarding failing on different types of errors: doing that is a possibility, once you bump up a minor version. My idea was to keep this as a patch i.e. without breaking backwards compatibility, at least to start with. There's nothing that says you can't do both though (e.g. add option for M.m.[p+1], start throwing stuff in M.[m+1].0).

For my use-case though, I need it to be able to fail when the file is missing or any other issue with it.

@cbrunnkvist
Copy link
Author

(Oh, the build failure is just because CODECLIMATE_REPO_TOKEN is missing -> unless you manage to get access to the secret token during PR builds, I would separate that step out to a separate build)

@mrsteele
Copy link
Owner

mrsteele commented Oct 6, 2017

I hear everything you are saying @cbrunnkvist but I also am challenged by this due to the fact that dotenv doesn't do this (or does it? I couldn't find anything in their docs that state this).

This could also be resolved as a build step validation to determine first if the file is set. I think that would solve your problem but I also want to make sure this is a problem others have run into. This is a good use case you stated above but also not sure if it needs to be dotenv-webpacks responsibility.

@mrsteele
Copy link
Owner

mrsteele commented Oct 13, 2017

@cbrunnkvist what do you think about using the dotenv-safe features to fail the build when missing something? You could use NODE_ENV which is universally used.

@codecov
Copy link

codecov bot commented Oct 16, 2017

Codecov Report

❗ No coverage uploaded for pull request base (master@8cac518). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##             master    #87   +/-   ##
=======================================
  Coverage          ?   100%           
=======================================
  Files             ?      1           
  Lines             ?     36           
  Branches          ?      0           
=======================================
  Hits              ?     36           
  Misses            ?      0           
  Partials          ?      0
Impacted Files Coverage Δ
src/index.js 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8cac518...92f438c. Read the comment docs.

@FDiskas
Copy link

FDiskas commented Dec 19, 2017

Then env is missing it should always fail and ci should stop i think ,🙄

@mrsteele
Copy link
Owner

Closing due to lack of participation.

Feel free to reopen this if you still think this is pertinent, thanks.

@mrsteele mrsteele closed this Oct 14, 2018
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

Successfully merging this pull request may close these issues.

None yet

3 participants