-
-
Notifications
You must be signed in to change notification settings - Fork 860
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
Add support for throwing if failed #165
Conversation
I think a better alternative would be to return the error instead of false so consumers can handle the error as they please (throw, report, ignore, etc.) |
Yeah, it's better than returning |
Please correct me if I'm wrong. The motivation to add an option to throw the error is to control how the error is handled. Instead of adding options, perhaps it's better to remove one and change what's returned from import { config } from 'dotenv'
import variableExpansion from 'dotenv-expand'
env = config()
if (env.error) {
// handle error as you like
throw env.error
}
variableExpansion(env.parsed) This is a low-impact path forward for anyone upgrading major versions. It allows people to continue ignoring errors that are most likely due to a missing file in environments like CI.
|
182505f
to
0879b15
Compare
0879b15
to
25ffb08
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good. will wait for more feedback and review before merging
This looks good my only concern is with the the return object change and external plugins that do not have I do not think there is many of these plugins out there, but I do think it would be a good idea, if this is merged, that we make either PRs or issues to update to support both versions. So that way on release we are not breaking those plugins functionality. |
other modules should specify peer dependencies to indicate which versions of dotenv they are compatible with |
I agree. 👍 for this PR |
If
verbose: 'throw'
is passed in options, anError
is thrown instead ofconsole.error
ing to the stdout