git-env-checker
v1.0.0
Published
CLI tool to check if .env files are listed in .gitignore
Maintainers
Readme
git-env-checker
A CLI tool to check if .env files are properly listed in .gitignore to prevent accidentally committing sensitive environment variables.
Installation
No installation needed! Just run it with npx:
npx git-env-checkerUsage
Navigate to your project directory and run:
npx git-env-checkerThe tool will:
- Scan the current directory (and subdirectories) for
.envfiles - Check if
.envpatterns are listed in.gitignore - Show a HIGH ALERT if
.envfiles are not protected by.gitignore
Example Output
When .env files are NOT in .gitignore:
🔍 Scanning for .env files...
Found 2 .env file(s):
- .env
- .env.local
🚨 HIGH ALERT: .env files are NOT listed in .gitignore!
This is a security risk. Please add .env files to your .gitignore:
echo ".env*" >> .gitignore
echo "**/.env*" >> .gitignoreWhen .env files are properly protected:
🔍 Scanning for .env files...
Found 1 .env file(s):
- .env
✅ .env files are properly listed in .gitignorePublishing
Setup
Get your npm token:
- Log in to npm:
npm login - Or create a token at https://www.npmjs.com/settings/YOUR_USERNAME/tokens
- Log in to npm:
Set the token as an environment variable:
export NPM_TOKEN=your_npm_token_hereOr add it to your
~/.zshrcor~/.bashrc:echo 'export NPM_TOKEN=your_npm_token_here' >> ~/.zshrc source ~/.zshrc
Publishing Commands
Dry run (test without publishing):
npm run publish:dry-runPublish patch version (1.0.0 → 1.0.1):
npm run publish:patchPublish minor version (1.0.0 → 1.1.0):
npm run publish:minorPublish major version (1.0.0 → 2.0.0):
npm run publish:majorManual publish:
npm publish
The prepublishOnly script will automatically run the env checker before publishing.
License
MIT
