chkenv
The environment variable detective your codebase needs.
A command-line tool to analyze environment variables in your project. It helps you identify unused environment variables declared in your .env
file and undeclared environment variables used in your code.
Features
- Detects unused environment variables
- Identifies undeclared variables in code
- Interactive cleanup with backup options
- Supports both
process.env
andimport.meta.env
- Smart comment handling with
--all
flag - Cleanup options for unused variables
- Automatic backup management
- Multiple file type support
Installation
Usage
Options
Interactive Mode
When run without the -d
flag, chkenv will prompt for:
- Directory to analyze
- Environment file name
- Comment handling preference
- Cleanup options for unused variables
Examples
Quick analysis with defaults:
Include commented variables:
Custom Directory Scan:
Custom Configuration file:
Cleanup options:
Using multiple flags:
Backup Management
When cleaning up unused variables, chkenv offers three backup options:
- Overwrite existing backup
- Create new numbered backup (e.g., .env.backup.1)
- Specify custom backup name
Example backup workflow:
File Support
Excluded Directories
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Contact
For any help or queries, you can reach out to me on X | LinkedIn | Peerlist.