https://github.com/itsfarseen/dotenv-test
https://github.com/itsfarseen/dotenv-test
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/itsfarseen/dotenv-test
- Owner: itsfarseen
- Created: 2022-06-08T08:46:51.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-08T08:50:58.000Z (about 4 years ago)
- Last Synced: 2025-03-08T21:11:22.879Z (over 1 year ago)
- Language: Rust
- Size: 1.95 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Test to see if we can override `dotenv()`
Contents of `.env`:
```
export FOO=bar
```
Contents of `.env.test`:
```
export FOO=test
```
```bash
$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `target/debug/dotenv-test`
FOO=bar
$ source .env.test
$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `target/debug/dotenv-test`
FOO=test
```
# What happens here
`dotenv()` won't overwrite existing env vars.
This allows us to override env vars by either doing `FOO=xyz cargo run` or `export FOO=xyz; cargo run`.
In both cases, `dotenv()` won't overwrite `FOO=bar` from the `.env` file.