Remove files created in the last run but not anymore in the current one
Last updated 5 years ago by zoubin .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install clean-remains 
SYNC missed versions from official npm registry.


version status node

Remove files created in the last run but not anymore in the current one.

In development environment, build process are run 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.


The following example make the 'build' directory always has the same contents with the 'src' directory.

const gulp = require('gulp')
const clean = require('clean-remains').glob('build/*.js')

gulp.task('sync', function () {
  return gulp.src('src/*.js')
    .once('delete', files => console.log(files))

gulp.task('watch', ['sync'], function () {'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.


const Clean = require('clean-remains')

clean = Clean(initialFiles)

Return a function like a gulp plugin, which should be used after gulp.dest.


Type: Array


If there are no redundant files before the first run, you could pass an empty array.

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.

Current Tags

  • 0.1.0                                ...           latest (5 years ago)

1 Versions

  • 0.1.0                                ...           5 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (3)
Dependents (2)

Copyright 2014 - 2017 © |