Env-mage Docs

Scan

Find env usage

scan

Finds environment variable usage in your code by scanning for process.env.

Usage

env-mage scan [options]

Options

OptionDescriptionDefault
--dir <path>Directory to scancurrent directory
--include <pattern>File patterns to include**/*.{js,ts,jsx,tsx}
--exclude <pattern>File patterns to excludenode_modules,dist,build
--compare <file>Compare found variables with env filenone

Example

env-mage scan --dir ./src --compare .env

Example 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 --compare to find variables used in code but missing from .env
  • Also shows .env variables that aren't used in code
  • Helps keep your environment configurations clean and complete