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

no error property set when .env file is not present #41

Closed
vineetdigit opened this issue Jan 14, 2021 · 3 comments · Fixed by #70
Closed

no error property set when .env file is not present #41

vineetdigit opened this issue Jan 14, 2021 · 3 comments · Fixed by #70
Labels
enhancement New feature or request

Comments

@vineetdigit
Copy link

vineetdigit commented Jan 14, 2021

Upon calling .config(), dotenv sets an error property in the returned object when .env is not present.

var result = require("dotenv").config();

// result.error property is set when .env is not present in the root directory of the node project

dotenv-flow does not set an error property, and instead it only has an empty "parsed" object.

var result = require("dotenv-flow).config();

// restult.error is not present, but result.parsed is an empty object

It would be nice to have a consistent behavior as "dotenv"

@kerimdzhanov
Copy link
Owner

Hey @vineetdigit,

The reason for such difference in behavior is that in "dotenv-flow", we may not have .env file (while having i.e. .env.development, .env.production, etc.,), so we can't consider it as an error.

On the other hand, if we have no .env* files at all, this behavior might be reasonable.

What are your thoughts?

@vineetdigit
Copy link
Author

vineetdigit commented Jan 25, 2021

My exact thoughts. As long as at least one of the files is present and it was successfully parsed, then result.parsed property will contain parsed values and result.error property should be undefined. Otherwise, result.error property will be set but the result.parsed will be undefined or an empty object.

@kerimdzhanov
Copy link
Owner

I see. Thanks for your thoughts and the idea in general!

kerimdzhanov added a commit that referenced this issue Aug 27, 2023
With this change dotenv-flow's `.config()` method will start returning an error if there is no appropriate ".env*" files were found.

Closes #41.
kerimdzhanov added a commit that referenced this issue Aug 27, 2023
…found

With this change dotenv-flow's `.config()` method will start returning an error if there is no appropriate ".env*" files.

Closes #41.
kerimdzhanov added a commit that referenced this issue Aug 28, 2023
…#70)

With this change dotenv-flow's `.config()` method will start returning
an error if none of the appropriate ".env*" files is found.

Closes #41.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants