https://github.com/schadokar/scan-env
Scan Env is a simple npm package that scan required environment variables in the .env file.
https://github.com/schadokar/scan-env
dotenv environment-variables
Last synced: 8 months ago
JSON representation
Scan Env is a simple npm package that scan required environment variables in the .env file.
- Host: GitHub
- URL: https://github.com/schadokar/scan-env
- Owner: schadokar
- License: mit
- Created: 2021-09-12T08:38:01.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-01-30T05:53:45.000Z (over 3 years ago)
- Last Synced: 2025-03-23T19:44:32.474Z (about 1 year ago)
- Topics: dotenv, environment-variables
- Language: JavaScript
- Homepage:
- Size: 37.1 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Scan Env
Scan Env is a simple npm package which reads required environment variables
from `.env.example` and scan those in `.env`. It uses `dotenv` in background to load the `.env` file.
It returns a boolean.
[npm package link](https://www.npmjs.com/package/scan-env)
## Install
```
npm install scan-env
```
## Use
### With default files
- Environment File Name: `.env`
- Env Example File Name: `.env.example`
- Env Ignored File Name: `.envignore`
```js
const scanEnv = require("scan-env");
const scanResult = scanEnv();
if (!scanResult) {
console.error("Environment variables are missing.");
}
```
### With custom files
- Environment File Name: `.prod.env`
- Env Example File Name: `.prod.env.example`
- Env Ignored File Name: `.prod.envignore`
```js
const scanEnv = require("scan-env");
const scanResult = scanEnv(".prod.env", ".prod.env.example", ".prod.envignore");
if (!scanResult) {
console.error("Environment variables are missing.");
}
```
## File Details
- `.env` file saves the original environment values.
- `.env.example` list all the env keys required by the application. Syntax of this env file must be like `.env`.
- `.envignore` list all the env keys which can be ignored if are missing.