# rev-del

> Delete replaced files from an old manifest

Latest version **2.0.0** (published 2019-01-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install rev-del
pnpm add rev-del
yarn add rev-del
bun add rev-del
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2019-01-23 |
| First published | 2015-02-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 10.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 35 |
| Author | Callum Macrae |
| Maintainers | callumacrae |
| Keywords | gulpplugin, gulpfriendly, rev, revision, hash, version, versioning |

## Links

- npm: https://www.npmjs.com/package/rev-del
- Repository: https://github.com/callumacrae/rev-del
- Issues: https://github.com/callumacrae/rev-del/issues
- npm.io page: https://npm.io/package/rev-del

## Dependencies (5)

- [del](https://npm.io/package/del.md) ^3.0.0
- [mocha](https://npm.io/package/mocha.md) ^5.2.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.11
- [should](https://npm.io/package/should.md) ^13.2.3
- [through2](https://npm.io/package/through2.md) ^3.0.0

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2019-01-23
- 1.0.5 — 2015-08-03
- 1.0.4 — 2015-02-20
- 1.0.3 — 2015-02-12
- 1.0.2 — 2015-02-11
- 1.0.1 — 2015-02-09
- 1.0.0 — 2015-02-09

## README

# rev-del [![Build Status](https://travis-ci.org/callumacrae/rev-del.svg)](https://travis-ci.org/callumacrae/rev-del)

Delete old, unused fingerprinted files from a revision manifest generated by a
module such as [gulp-rev].

## Install

```
$ npm install --save-dev rev-del
```

## Usage

```js
revDel({
	oldManifest: 'rev-manifest.json',
	newManifest: { /* a manifest */ },
	suppress: true, 
	deleteMapExtensions: false
}, function (err, filesDeleted) {
	// ...
});
```

The manifests can be either objects or paths to files. `oldManifest` defaults
to "rev-manifest.json" (which is the default output for gulp-rev), and
newManifest has no default; it's assumed that you've got it in memory, so it's
more efficient to pass it in as an object.

`suppress`, when set to false, will throw an error when rev-manifest.json
doesn't exist. You don't normally want to change: usually, the first time you
run your revisioning script, the manifest doesn't exist yet.

`deleteMapExtensions`, when set to true, will try and find any ".map" files generated by [gulp-sourcemaps](//github.com/gulp-sourcemaps/gulp-sourcemaps) belonging to changed files in `oldManifest` and delete those too.

### With Gulp

rev-del works great with Gulp and gulp-rev. You need to specify either `dest`
in the options, or `base` in the manifest options—unless you're writing
everything to the root directory.

```js
var gulp = require('gulp');
var rev = require('gulp-rev');
var revDel = require('rev-del');

gulp.task('default', function () {
    return gulp.src('src/*.css')
        .pipe(rev())
        .pipe(gulp.dest('dist'))
        .pipe(rev.manifest())
        .pipe(revDel({ dest: 'dist' }))           // <--
        .pipe(gulp.dest('dist'));
});
```

You can pass it the name of the old manifest if you're not using the default:

```js
var gulp = require('gulp');
var rev = require('gulp-rev');
var revDel = require('rev-del');

gulp.task('default', function () {
    return gulp.src('src/*.css')
        .pipe(rev())
        .pipe(gulp.dest('dist'))
        .pipe(rev.manifest('my-manifest.json'))
        .pipe(revDel('some-other-manifest.json'))        // <--
        .pipe(gulp.dest('dist'));
});
```

Call it **before** you call `gulp.dest`.

Note that you only need to change the name of manifest if it is different to
the path given to `rev.manifest()`: if you just change the name of the
manifest, rev-del will handle it fine:

```js
// This works
var gulp = require('gulp');
var rev = require('gulp-rev');
var revDel = require('rev-del');

gulp.task('default', function () {
    return gulp.src('src/*.css')
        .pipe(rev())
        .pipe(gulp.dest('dist'))
        .pipe(rev.manifest('my-manifest.json'))
        .pipe(revDel({ dest: 'dist' }))                          // <--
        .pipe(gulp.dest('dist'));
});
```

You can also specify the `base` as one of the options. Again, you don't need to
do this if you've given it to `rev.manifest()`!

You can also add `force: true` as an option. This is passed through to the underlying [del](https://github.com/sindresorhus/del#optionsforce) plugin which accepts it to allow deletion outside the current working directory. This comes in handy when you get a gulp error like 'Cannot delete files/folders outside the current working directory. Can be overriden with the `force` option.'

## License

Released under the MIT license.


[gulp-rev]: https://github.com/sindresorhus/gulp-rev

---
_Source: https://npm.io/package/rev-del · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
