-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from ya55en/pass-silently-when-dotenv-file-none…
…xistent Treat a non-existent dotenv file as an empty one
- Loading branch information
Showing
5 changed files
with
23 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
# dotenv | ||
|
||
Loads .env file in Crystal and optionally loads them directly into your ENV var: https://crystal-lang.org/api/0.27.0/ENV.html | ||
Will always return the .env file as a hash regardless of whether you chose to load into your ENV or not | ||
Loads a .env file in Crystal and optionally sets values directly into your [ENV](https://crystal-lang.org/api/latest/ENV.html). | ||
Will always return the .env file as a hash regardless of whether you chose to load into your `ENV` or not. Will treat a non-existent | ||
.env file as an empty one. | ||
|
||
## Installation | ||
|
||
|
@@ -34,21 +35,21 @@ DB_PORT=3306 | |
DB_DATABASE=test | ||
``` | ||
##### Using a file called .env and loading into your ENV var | ||
##### Using a file called .env and loading into your `ENV` | ||
```crystal | ||
require "dotenv" | ||
Dotenv.load # => {"ENV" => "dev", "PORT" => "3000", "LOGGING" => "true", "CORS" => "*", "DB_DRIVER" => "mysql", "DB_USERNAME" => "root", "DB_PASSWORD" => "password", "DB_HOST" => "localhost", "DB_PORT" => "3306", "DB_DATABASE" => "test"} | ||
``` | ||
|
||
##### Using a file called .env and NOT loading into your ENV var | ||
##### Using a file called .env and NOT loading into your `ENV` | ||
```crystal | ||
require "dotenv" | ||
hash = Dotenv.load(set_env: false) | ||
``` | ||
|
||
##### Using a file NOT called .env and loading into your ENV var | ||
##### Using a file NOT called .env and loading into your `ENV` | ||
```crystal | ||
require "dotenv" | ||
|
@@ -66,7 +67,10 @@ hash = Dotenv.load(override_env: false) | |
|
||
## Development | ||
|
||
TODO: Write development instructions here | ||
1. Clone the repository: `git clone [email protected]:drum445/dotenv.git`. | ||
There are no dependencies, so no `shards install` is needed (but won't do any harm). | ||
3. Change into the project root directory: `cd dotenv`. | ||
2. Run specs: `crystal spec`. | ||
|
||
## Contributing | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name: dotenv | ||
version: 0.4.0 | ||
version: 0.5.0 | ||
|
||
authors: | ||
- drum445 <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# An empty .env file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters