yaroslavpysarvalidos
v1.0.1
Published
yaroslavpysarvalidos
Downloads
6
Readme
env-inspector
🔍 A simple CLI tool to inspect .env files and check for unused or missing environment variables in your JavaScript or TypeScript project.
📦 Installation
You can install it globally or use with npx.
npm install -g env-inspectorOr run directly with:
npx env-inspector🚀 Usage
Make sure you have:
- a
.envfile in your project root - your source files in the
src/folder
Then run:
env-inspectorYou will get an output like:
🔍 Inspecting environment variables...
✅ Found 5 variables in .env
📦 Used 4 variables in source files
⚠️ Unused variables in .env: DEBUG
❌ Variables used but not defined in .env: API_SECRET🧠 What It Does
- Reads and parses your
.envfile. - Recursively searches through
src/directory. - Detects
process.env.VARIABLE_NAMEusages. - Compares defined and used variables.
- Reports:
- ✅ All good
- ⚠️ Defined but unused
- ❌ Used but not defined
✅ Example .env
API_URL=https://api.example.com
TOKEN_SECRET=xyz123
DEBUG=true👨💻 Example Code
console.log(process.env.API_URL);
console.log(process.env.TOKEN_SECRET);📄 License
MIT
Made with ❤️ by Yaroslav Pysar
