https://github.com/canastro/remove-git-ignored
:tractor: Small library that finds all directories with a .gitignore file and removes all the ignored files.
https://github.com/canastro/remove-git-ignored
Last synced: over 1 year ago
JSON representation
:tractor: Small library that finds all directories with a .gitignore file and removes all the ignored files.
- Host: GitHub
- URL: https://github.com/canastro/remove-git-ignored
- Owner: canastro
- Created: 2017-01-15T10:37:30.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-17T20:40:46.000Z (over 9 years ago)
- Last Synced: 2025-02-25T12:40:48.012Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 2
- Watchers: 1
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

[](https://badge.fury.io/js/remove-git-ignored)
[](https://codecov.io/gh/canastro/remove-git-ignored)
# remove-git-ignored
Small library that will find all `.gitignore` files from a `rootPath` folder and will delete all the ignored files.
## Why?
I had a lot of old projects that I didn't worked for a while and I was running out of free space on my disk. I ran a command that would delete all the `node_modules` folders in a given rootPath and I "instantly" gained 20GB of free disk.
After that I thought I should have a better way to deal with this and started creating a electron application to manage my workspace, and created a few of core modules to support it, such as:
* [query-paths](https://github.com/canastro/query-paths)
* [remove-git-ignored](https://github.com/canastro/remove-git-ignored)
* [bulk-run-nsp](https://github.com/canastro/bulk-run-nsp)
## How it works?
This module uses [query-paths](https://github.com/canastro/query-paths) to recursively find all the folders with a .gitignore. Then it reads all these files and deletes all files that match what you have defined in it.
## Demo
[](https://asciinema.org/a/3p1wtf72uqon9zyc7kwtdmue0)
## Usage
### As cli
```js
> npm i -g remove-git-ignored
# Go to the desired root folder
> remove-git-ignored
```
### As a node module
```js
const removeGitIgnored = require('remove-git-ignored');
const remove = removeGitIgnored({
rootPath: '/Users/username/dev',
isSilent: true // false to show user confirmation prompts
});
remove.on('project-start', (path) => {
console.log('project started: ', path);
});
remove.on('file-deleted', (file) => {
console.log('file deleted: ', file);
});
remove.on('project-completed', (path) => {
console.log('project completed: ', path);
});
remove.on('end', () => {
console.log('end');
});
```