An open API service indexing awesome lists of open source software.

https://github.com/mgks/env-must-exist

CLI to assert that environment variables are present. Fails fast in CI/CD if missing.
https://github.com/mgks/env-must-exist

automation ci cli failsafe nodejs npm

Last synced: 5 months ago
JSON representation

CLI to assert that environment variables are present. Fails fast in CI/CD if missing.

Awesome Lists containing this project

README

          

# env-must-exist

**Assert that environment variables are present. Fail fast in CI.**


npm version
size
npm downloads
license

A tiny pre-flight check that stops broken deploys before they happen. It verifies required environment variables like `DATABASE_URL` at deploy time and fails fast with a clear error if anything is missing, instead of letting your app crash later in production in confusing ways.

## Installation

```bash
npm install env-must-exist
```

## Usage

### CLI (Recommended for CI)

Add this to your build or start script:

```bash
{
"scripts": {
"build": "env-must-exist DATABASE_URL STRIPE_KEY && next build"
}
}
```

If `STRIPE_KEY` is missing, you get:

```bash
❌ Missing required environment variables:
- STRIPE_KEY
```

### API

```js
import { assertEnv } from 'env-must-exist';

assertEnv(['DATABASE_URL', 'API_KEY']);
```

## License

MIT

> **{ github.com/mgks }**
>
> ![Website Badge](https://img.shields.io/badge/Visit-mgks.dev-blue?style=flat&link=https%3A%2F%2Fmgks.dev) ![Sponsor Badge](https://img.shields.io/badge/%20%20Become%20a%20Sponsor%20%20-red?style=flat&logo=github&link=https%3A%2F%2Fgithub.com%2Fsponsors%2Fmgks)