Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tanishqmanuja/consistent-env
Consistent environment variables across runtimes.
https://github.com/tanishqmanuja/consistent-env
bun dotenv env node
Last synced: about 1 month ago
JSON representation
Consistent environment variables across runtimes.
- Host: GitHub
- URL: https://github.com/tanishqmanuja/consistent-env
- Owner: tanishqmanuja
- License: bsd-2-clause
- Created: 2024-04-21T11:32:33.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-04-23T06:27:03.000Z (9 months ago)
- Last Synced: 2024-10-30T08:43:40.915Z (2 months ago)
- Topics: bun, dotenv, env, node
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@tqman/env
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @tqman/env
A thin wrapper around [**dotenv**](https://github.com/motdotla/dotenv) for providing consistent experience with loading environment variables across different runtimes.
## 📦 Install
Install using `npm`
```bash
npm install dotenv@latest @tqman/env@latest
```Install using `bun`
```bash
bun install dotenv@latest @tqman/env@latest
```## ⚙️ Loading Strategy
Environment variables are loaded in the following order:
- .env
- .env.{mode} (mode is NODE_ENV lowercased, default is development)
- .env.localStrategy is a mix of both [**bun**](https://bun.sh/docs/runtime/env), [**vite**](https://vitejs.dev/guide/env-and-mode).
> [!NOTE]
> Difference from Bun's strategy - bun only supports .env.{mode} when mode is production, development or test.
> Issue: https://github.com/oven-sh/bun/issues/9090> [!NOTE]
> Difference from Vite's strategy - .env.{mode}.local is loaded by default in vite, but not by this library.## 👨💻 Usage
As a side effect import
```ts
import "@tqman/env/load";
```As a function call
```ts
import { load } from "@tqman/env";load();
```