-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: setting comments and adding non-existing entries
- Loading branch information
Showing
4 changed files
with
71 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# .env File Entries Manager | ||
|
||
This package allows you to easily manage `.env` file entries in a type-safe manner. | ||
|
||
## Usage | ||
|
||
```ts | ||
|
||
let dotEnv = new DotEnv(`EXAMPLE_NUMBER_FIELD=123`); | ||
|
||
// retrieving | ||
const exampleNumberEntry = dotEnv.get<number>('EXAMPLE_NUMBER_FIELD'); | ||
|
||
console.log(exampleNumberEntry.key); // string ("EXAMPLE_NUMBER_FIELD") | ||
console.log(exampleNumberEntry.value); // number (123) | ||
console.log(exampleNumberEntry.comment); // undefined | ||
|
||
// setting values and comments | ||
dotEnv.set('EXAMPLE_NUMBER_FIELD', 456); | ||
dotEnv.setComment('EXAMPLE_NUMBER_FIELD', 'Example comment'); | ||
|
||
dotEnv.set('NEW_FIELD', 'test'); | ||
|
||
// formatting entries to string | ||
console.log(dotEnv.toString()); // "EXAMPLE_NUMBER_FIELD=456 # Example comment\nNEWFIELD=test" | ||
``` |
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
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