https://github.com/zaida04/tomlenv
🤫 Read and inject environment variables from a .toml file. Inspired by dotenv. Made with ❤️
https://github.com/zaida04/tomlenv
Last synced: about 1 year ago
JSON representation
🤫 Read and inject environment variables from a .toml file. Inspired by dotenv. Made with ❤️
- Host: GitHub
- URL: https://github.com/zaida04/tomlenv
- Owner: zaida04
- License: mit
- Created: 2022-02-14T22:22:16.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-14T22:43:18.000Z (over 4 years ago)
- Last Synced: 2024-05-02T04:06:00.750Z (about 2 years ago)
- Language: TypeScript
- Homepage:
- Size: 90.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# `tomlenv`
[](https://github.com/zaida04/tomlenv/blob/main/LICENSE)
[](https://www.npmjs.com/package/tomlenv)
[](https://github.com/zaida04/tomlenv/actions/workflows/ci.yml)
## 🗒️ About
Read and inject environment variables from a .toml file. Inspired by [dotenv](https://www.npmjs.com/package/dotenv)
## 📥 Installation
You can install this package from [NPM](https://www.npmjs.com/package/tomlenv)
- `npm install tomlenv`
- `yarn add tomlenv`
## ⚡ Usage
### Unstructured env toml file
`.env.toml`
```toml
test = "TESTING_VAR_1"
test2 = "TESTING_VAR_2"
```
`index.js`
```typescript
import * as tomlenv from 'tomlenv';
tomlenv.config({ path: '../path/to/some/.env.toml' });
console.log(process.env);
/*
{
...,
test: "TESTING_VAR_1",
test2: "TESTING_VAR_2"
}
*/
```
### Structured env toml file
`.env.toml`
```toml
[env.prod]
test = "TESTING_VAR_1_PROD"
test2 = "TESTING_VAR_2_PROD"
[env.dev]
test = "TESTING_VAR_1_DEV"
test2 = "TESTING_VAR_2_DEV"
```
`index.js`
```typescript
import * as tomlenv from 'tomlenv';
tomlenv.config({ path: '../path/to/some/.env.toml', environment: 'dev' });
console.log(process.env);
/*
{
...,
test: "TESTING_VAR_1_DEV",
test2: "TESTING_VAR_2_DEV"
}
*/
```
## ✋ Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
Please ensure any and all commits pass our tests, linting, and build steps as described in the package.json. Our husky/commitlint commit hooks should take care of this for you automatically.
## ⚖️ LICENSE
Licensed under the [MIT License](https://github.com/zaida04/tomlenv/blob/main/LICENSE)