Scan
Find env usage
scan
Finds environment variable usage in your code by scanning for process.env.
Usage
env-mage scan [options]Options
| Option | Description | Default |
|---|---|---|
--dir <path> | Directory to scan | current directory |
--include <pattern> | File patterns to include | **/*.{js,ts,jsx,tsx} |
--exclude <pattern> | File patterns to exclude | node_modules,dist,build |
--compare <file> | Compare found variables with env file | none |
Example
env-mage scan --dir ./src --compare .envExample Output
✓ Scanning directory: ./src
✓ Found 62 files matching pattern
✓ Analyzing files for environment variable usage
✓ Found 14 unique environment variables:
Variable | Files | References
-------------------|-------|----------
DATABASE_URL | 4 | 8
API_KEY | 7 | 12
DEBUG | 2 | 6
PORT | 1 | 3
✓ Comparing with .env file
⚠ Missing from .env: STRIPE_SECRET, REDIS_URL
⚠ Unused in code: SESSION_SECRET, TEMP_DIR
✓ Scan completed!Things to Know
- Finds all
process.env.*references in your code - Use
--compareto find variables used in code but missing from.env - Also shows
.envvariables that aren't used in code - Helps keep your environment configurations clean and complete