Dragory / gulp-hash

A gulp plugin for cachebusting files by adding a hash to their name and/or content.
MIT License
69 stars 24 forks source link

"Delete old output files if original files were changed" functionality was added #18

Closed MEGApixel23 closed 7 years ago

MEGApixel23 commented 7 years ago

In a current version of this package if there is original file app.js and a user runs gulp task it will generate an output file (e.g. app-111111.js). If a content of original file app.js is changed and gulp task is run again different output file (e.g. app-222222.js) and the old one will exist as well.

This pull request adds functionality that helps to keep only one version of an output file and deletes old unneeded versions if they are redundant. A new version of a package supports old signature and provides backward compatibility for existing usage of hash.manifest() method.

Basic usage of a new function:

hash.manifest('manifest.json', {
  deleteOld: true,
  sourceDir: __dirname + '/public/js'
});
davePlug commented 7 years ago

Can we merge this? @Dragory

Dragory commented 7 years ago

Yeah sure. I'll just clean up the merge first since it touches line indentations and stuff.

Dragory commented 7 years ago

Merged. Thank you for the PR!