-
Notifications
You must be signed in to change notification settings - Fork 9
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 loading env values #23
base: main
Are you sure you want to change the base?
Conversation
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.
Could you move the parsing code to it's own file that is imported into index.ts
? It's about doubled the length of the file, so I think it'll help readability.
Great work, I think this will definitely help us going forward as it's one less dependency in our projects. In the future, I would love to see us add support for multiple .env
files similar to dotenv-flow
since some of our projects will still need to use that for multiple environments.
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.
I think this should just about wrap it up for this PR, please let me know if there's anything else I missed and I'll try to get to it quickly!
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.
Two big things in addition to a question (and more feedback from @johnkahn):
- Make sure to update the README with info about how to use it (make sure to make restrictions clear and add a snippet to show an example of it being used)
- Since this is a rather significant feature addition, make sure to bump the minor version in both of the package files
This is going to be an awesome addition!!! Thanks for doing this 😄
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.
A couple README updates.
Also reading through the example I want to make sure that the implementation here matches what dotenv does so it's an easy swap for people. Looks like we have some extra stuff (like //
comments) and we're missing some things. @SpencerKaiser what is your thought on changing envPath
to experimentalEnvPath
and merging as is? Then changing it to envPath
once it matches?
Co-authored-by: John Kahn <[email protected]>
Co-authored-by: John Kahn <[email protected]>
I don't think adding But we definitely want our parser to handle the same cases as DotEnv so that it's easy for people to swap to our package painlessly. I'll re-work it a bit to cover all those cases. |
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.
Just a few quick things and then I think we can merge!
|
||
If you set a path to an `.env` file, `simple-env` will parse the file and import the contents into the environment automatically. These will be available in the `process.env` object. | ||
|
||
> If you don't specify a path, `simple-env` **will not** automatically load any `.env` files. This is to avoid a breaking change. |
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.
> If you don't specify a path, `simple-env` **will not** automatically load any `.env` files. This is to avoid a breaking change. | |
> :warning: **NOTE**: If you don't specify a path, `simple-env` **will not** automatically load any `.env` files. |
someRequiredSecret: 'SOME_REQUIRED_SECRET', | ||
}, | ||
options: { | ||
envPath: "./.env" |
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.
This should work as well. Do you think the original is better?
envPath: "./.env" | |
envPath: ".env" |
} | ||
}); | ||
``` | ||
Each variable needs to be declared on a separate line. |
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.
Let's add all of this to a new sub-section called Correct .env Syntax
(or something like it). To keep the README simple, can we add all of that to a <details>
tag?
@@ -1,3 +1,5 @@ | |||
.vscode |
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.
Including that file was intentional; revert this
@johnkahn I'm ok with the rules as of now; while I don't want to encourage And re: |
@SpencerKaiser I was wondering if having And for |
Pre-Requisites
Description of Changes
Extends the capabilities of dotenv-flow, so the users of this package don't need to install both packages.
simple-env should play nice with
.env
files out of the box :^)Related Issues
Closes Add support for loading env values