Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zoubin/clean-remains
Remove files created in the last run but not anymore in the next
https://github.com/zoubin/clean-remains
Last synced: 8 days ago
JSON representation
Remove files created in the last run but not anymore in the next
- Host: GitHub
- URL: https://github.com/zoubin/clean-remains
- Owner: zoubin
- License: mit
- Created: 2016-02-26T07:00:37.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-02-26T10:33:42.000Z (over 8 years ago)
- Last Synced: 2024-11-07T06:40:36.388Z (12 days ago)
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# clean-remains
[![version](https://img.shields.io/npm/v/clean-remains.svg)](https://www.npmjs.org/package/clean-remains)
[![status](https://travis-ci.org/zoubin/clean-remains.svg)](https://travis-ci.org/zoubin/clean-remains)
![node](https://img.shields.io/node/v/clean-remains.svg)Remove files created in the last run but not anymore in the current one.
In development environment, build process runs once a file change detected.
If a file is removed, the corresponding compiled file (like a browserify bundle) remains,
which is redundant and should be deleted.## Example
The following example make the `'build'` directory always has the same contents with the `'src'` directory.
```javascript
const gulp = require('gulp')
const clean = require('clean-remains').glob('build/*.js')gulp.task('sync', function () {
return gulp.src('src/*.js')
.pipe(gulp.dest('build'))
.pipe(clean())
.once('delete', files => console.log(files))
})gulp.task('watch', ['sync'], function () {
gulp.watch('src/*.js', ['sync'])
})```
You could delete the whole `'build'` directory in the example above.
However, if you do that and there are also css files in the `'build'` directory,
they will be deleted against your will.## API
```javascript
const Clean = require('clean-remains')```
### clean = Clean(initialFiles)
Return a function like a gulp plugin,
which should be used after `gulp.dest`.**initialFiles**
Type: `Array`
Required.
If there are no redundant files before the first run,
you could pass an empty array.```javascript
const gulp = require('gulp')
const clean = require('clean-remains')([])```
### clean = Clean.glob(patterns, opts)
`patterns` and `opts` are passed to [`globby`] to create the `initialFiles`.