Skip to content

Scan Env is a simple npm package that scan required environment variables in the .env file.

License

Notifications You must be signed in to change notification settings

BrycensRanch/scan-env

 
 

Repository files navigation

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 either false or an array of missing environment variables.

orginial project

Install

npm install BrycensRanch/scan-env

Usage

With default files

  • Environment File Name: .env
  • Env Example File Name: .env.example
  • Env Ignored File Name: .envignore
const scanEnv = require("scan-env");

const scanResult = scanEnv();

if (scanResult.length) {
  console.error(`The following required environment variables are missing: ${scanResult.join(", ")}`);
}

With custom files

  • Environment File Name: .prod.env
  • Env Example File Name: .prod.env.example
  • Env Ignored File Name: .prod.envignore
const scanEnv = require("scan-env");

const scanResult = scanEnv(".prod.env", ".prod.env.example", ".prod.envignore");

if (scanResult.length) {
  console.error(`The following required environment variables are missing: ${scanResult.join(", ")}`);
}

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.

About

Scan Env is a simple npm package that scan required environment variables in the .env file.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 96.9%
  • Shell 3.1%