https://github.com/tailflow/dotenv
A simple Node.js package for managing .env file entries
https://github.com/tailflow/dotenv
Last synced: 10 days ago
JSON representation
A simple Node.js package for managing .env file entries
- Host: GitHub
- URL: https://github.com/tailflow/dotenv
- Owner: tailflow
- Created: 2022-09-11T07:54:35.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-01T16:58:28.000Z (over 2 years ago)
- Last Synced: 2025-05-02T13:19:36.372Z (about 2 months ago)
- Language: TypeScript
- Size: 109 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# .env File Entries Manager
This package allows you to easily manage `.env` file entries in a type-safe manner.
## Installation
```bash
npm install @tailflow/dotenv# or
yarn add @tailflow/dotenv
```## Usage
```ts
let dotEnv = new DotEnv(`EXAMPLE_NUMBER_FIELD=123`);
// retrieving
const exampleNumberEntry = dotEnv.get('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"
```