A command-line tool to clean junk files and folders from your projects
npm install gitcleaner-cli.gitcleaner.json
bash
npm install -g gitcleaner
`
Or run directly with npx:
`bash
npx gitcleaner scan
`
Usage
$3
`bash
gitcleaner scan
`
This will show you all the junk files and folders found in your current directory and subdirectories.
$3
`bash
gitcleaner clean
`
This will delete all detected junk files and folders.
$3
`bash
gitcleaner clean --dry-run
`
This will show you what would be deleted without actually deleting anything.
Default Patterns
GitCleaner looks for these common junk patterns by default:
- node_modules - Node.js dependencies
- dist - Build output directories
- build - Build output directories
- .DS_Store - macOS system files
- __pycache__ - Python cache directories
- *.log - Log files
- coverage - Test coverage reports
- .nyc_output - NYC coverage tool output
- *.tmp - Temporary files
- *.temp - Temporary files
- .cache - Cache directories
- tmp - Temporary directories
Custom Configuration
Create a .gitcleaner.json file in your project root to customize the patterns:
`json
{
"patterns": [
"node_modules",
"dist",
"build",
".DS_Store",
"*.log",
"custom-folder",
"*.custom"
]
}
`
Example Output
$3
`bash
$ gitcleaner scan
๐ Scanning for junk files...
Found junk:
- node_modules/ (550 MB)
- dist/ (12 MB)
- coverage/ (8.5 MB)
- .DS_Store (4 KB)
- app.log (2 KB)
Total: 570.5 MB
๐ก Run 'gitcleaner clean' to delete these files
`
$3
`bash
$ gitcleaner clean
๐งน Cleaning junk files...
- Deleted: node_modules/ (550 MB)
- Deleted: dist/ (12 MB)
- Deleted: coverage/ (8.5 MB)
- Deleted: .DS_Store (4 KB)
- Deleted: app.log (2 KB)
โ
Cleaned 5 items (570.5 MB freed)
`
$3
`bash
$ gitcleaner clean --dry-run
๐ Would delete junk files...
- Would delete: node_modules/ (550 MB)
- Would delete: dist/ (12 MB)
- Would delete: coverage/ (8.5 MB)
- Would delete: .DS_Store (4 KB)
- Would delete: app.log (2 KB)
๐ Would clean 5 items (570.5 MB would free)
`
Commands
| Command | Description |
|---------|-------------|
| gitcleaner scan | Scan for junk files and show results |
| gitcleaner clean | Delete all detected junk files |
| gitcleaner clean --dry-run | Preview what would be deleted |
| gitcleaner --help | Show help information |
| gitcleaner --version | Show version information |
Safety Features
- Git Ignored: Automatically ignores .git directories
- Smart Exclusions: Won't scan inside node_modules for performance
- Error Handling: Gracefully handles permission errors
- Confirmation: Clear output showing what will be/was deleted
Development
$3
1. Clone the repository
2. Install dependencies: npm install
3. Link for local testing: npm link
$3
`
gitcleaner/
โโโ index.js # Main CLI entry point
โโโ package.json # Package configuration
โโโ README.md # Documentation
โโโ .gitcleaner.json # Optional config file
`
Contributing
1. Fork the repository
2. Create your feature branch (git checkout -b feature/amazing-feature)
3. Commit your changes (git commit -m 'Add some amazing feature')
4. Push to the branch (git push origin feature/amazing-feature`)