-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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(core): add .env
support to Configuration
#4835
Conversation
db93568
to
e164f61
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
yarnrc.yml
support .env
yarnrc.yml
supports .env
yarnrc.yml
supports .env
.env
support to Configuration
d791aad
to
a8a79a0
Compare
3b789dd
to
b9a2887
Compare
b9a2887
to
a96b68c
Compare
a9cc2c7
to
8cc11b1
Compare
#4912 is merged 🎉!! So I came back to this PR. It has been more than a month since this PR was created, and during this period, I have been following yarn issues and yarn discord, but I still don't see any use cases that need multiple I think such use cases are quite rare, not to mention multiple so I think that I did originally over-design 🙈, for these rare use cases, I made the code more complex, making the review more difficult and increasing the chances of breaking change in the future, I prefer to make it simpler now. I made the following changes: 1. Rename
|
5517450
to
641f53b
Compare
641f53b
to
38c1c7d
Compare
**What's the problem this PR addresses?** A common need is to provide environment values into the environment via `.env` files. There's been a couple of issues and attempts at implementation already, which all were decently upvoted. I myself could have used it once or twice 😄 Props to @jj811208 for his implementation in #4835 - I wanted to make the configuration a little more generic (allowing to have multiple environment files, and to possibly disable it altogether), but it was a appreciated start. Fixes #4718 Closes #4835 (Supercedes it) **How did you fix it?** A new setting, `injectEnvironmentFiles`, lets you define files that Yarn will load and inject into all scripts. It only affects subprocesses - Yarn itself still uses `process.env` for its checks, so you can't for example set `YARN_*` values and expect them to be applied to the current process (use the yarnrc file for that instead). The `injectEnvironmentFiles` setting has a few properties: - It defaults to `.env` - Nothing will be injected if it's set to an empty array or null - The paths inside may be suffixed by `?` - in that case, Yarn won't throw if the file doesn't exist The idea with this last property is to allow for simple user configuration (imagine, with the example below, that the project also has a gitignore with `.env.*`): ``` injectEnvironmentFiles: - .env - .env.${USER}? ``` **Checklist** <!--- Don't worry if you miss something, chores are automatically tested. --> <!--- This checklist exists to help you remember doing the chores when you submit a PR. --> <!--- Put an `x` in all the boxes that apply. --> - [x] I have read the [Contributing Guide](https://yarnpkg.com/advanced/contributing). <!-- See https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released for more details. --> <!-- Check with `yarn version check` and fix with `yarn version check -i` --> - [x] I have set the packages that need to be released for my changes to be effective. <!-- The "Testing chores" workflow validates that your PR follows our guidelines. --> <!-- If it doesn't pass, click on it to see details as to what your PR might be missing. --> - [x] I will check that all automated PR checks pass before the PR gets reviewed.
What's the problem this PR addresses?
Closes #4718
related issue: #2724
related PR: #3938
I agree with this point because my project has the same problem.
I'm not sure about other use cases for env in yarn, but I guess as long as
yarnrc.yml
supports.env
, it should solve most of the use cases.production.env
,.development.env
,.test.env
..., only.env
yarnrc.yml
in the project, eachyarnrc.yml
will load both the.env
in the same directory and the.env
at the root of the project.How did you fix it?
dotenv@16.0.2
package 5ed9434findPackageEnv
630a7c9parseXxx
family of functions accept env parameters 1f961bayarnrc.yml
load the.env
file 1374abbConfiguration
ec7ed66Checklist