diff options
author | Arthur <192247+arteezy@users.noreply.github.com> | 2018-07-11 03:31:47 +0600 |
---|---|---|
committer | Marc CornellĂ <marc.cornella@live.com> | 2018-07-10 23:31:47 +0200 |
commit | 7cb5fa8aea3d325fee08e3c1708abd12cdea1c1c (patch) | |
tree | e50dca2317f68bd18acfff0b4db7a86d20819e89 | |
parent | be342b1bc8306cc24c2bb6145ceae78839a3008f (diff) | |
download | zsh-7cb5fa8aea3d325fee08e3c1708abd12cdea1c1c.tar.gz zsh-7cb5fa8aea3d325fee08e3c1708abd12cdea1c1c.tar.bz2 zsh-7cb5fa8aea3d325fee08e3c1708abd12cdea1c1c.zip |
Fix dotenv plugin accepted file format and clarify README (#6093)
* Fix dotenv plugin accepted file format
* clarify README and add disclaimer section
-rw-r--r-- | plugins/dotenv/README.md | 19 | ||||
-rw-r--r-- | plugins/dotenv/dotenv.plugin.zsh | 8 |
2 files changed, 22 insertions, 5 deletions
diff --git a/plugins/dotenv/README.md b/plugins/dotenv/README.md index ade09fbb2..e0e75571f 100644 --- a/plugins/dotenv/README.md +++ b/plugins/dotenv/README.md @@ -2,19 +2,19 @@ Automatically load your project ENV variables from `.env` file when you `cd` into project root directory. -Storing configuration in the environment is one of the tenets of a [twelve-factor app](http://www.12factor.net). Anything that is likely to change between deployment environments–such as resource handles for databases or credentials for external services–should be extracted from the code into environment variables. +Storing configuration in the environment is one of the tenets of a [twelve-factor app](http://www.12factor.net). Anything that is likely to change between deployment environments, such as resource handles for databases or credentials for external services, should be extracted from the code into environment variables. ## Installation Just add the plugin to your `.zshrc`: ```sh -plugins=(git man dotenv) +plugins=(... dotenv) ``` ## Usage -Create `.env` file inside your project directory and put your local ENV variables there. +Create `.env` file inside your project root directory and put your ENV variables there. For example: ```sh @@ -30,5 +30,16 @@ SECRET_KEY=7c6c72d959416d5aa368a409362ec6e2ac90d7f MONGO_URI=mongodb://127.0.0.1:27017 PORT=3001 ``` +You can even mix both formats, although it's probably a bad idea. -**It's strongly recommended to add `.env` file to `.gitignore`**, because usually it contains sensitive information such as your credentials, secret keys, passwords etc. You don't want to commit this file, it supposed to be local only. +## Version Control + +**It's strongly recommended to add `.env` file to `.gitignore`**, because usually it contains sensitive information such as your credentials, secret keys, passwords etc. You don't want to commit this file, it's supposed to be local only. + +## Disclaimer + +This plugin only sources the `.env` file. Nothing less, nothing more. It doesn't do any checks. It's designed to be the fastest and simplest option. You're responsible for the `.env` file content. You can put some code (or weird symbols) there, but do it on your own risk. `dotenv` is the basic tool, yet it does the job. + +If you need more advanced and feature-rich ENV management, check out these awesome projects: +* [direnv](https://github.com/direnv/direnv) +* [zsh-autoenv](https://github.com/Tarrasch/zsh-autoenv) diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh index 9dd784229..fa47c4c68 100644 --- a/plugins/dotenv/dotenv.plugin.zsh +++ b/plugins/dotenv/dotenv.plugin.zsh @@ -2,7 +2,13 @@ source_env() { if [[ -f .env ]]; then - source .env + if [[ -o a ]]; then + source .env + else + set -a + source .env + set +a + fi fi } |