jgable / gulp-cache

A cache proxy task for Gulp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

0.4.3 breaks cache behavior for plugins which change the file extension

janb87 opened this issue · comments

I'm using gulp cache in combination with gulp-less.

After the latest release (0.4.3) my build broke.

What happens if my file is in the cache:
0.4.2 Build styles.less => outputs styles.css
0.4.3 Build styles.less => outputs styles.less

var gulp = require('gulp');
var less = require('gulp-less');
var cache = require('gulp-cache');

gulp.src('**/*.less')
                .pipe(cache(less(), {
                    key: function (file) {
                        return [file.contents.toString('utf8'), file.path, 'less'].join('');
                    },
                    success: function (file) {
                        console.log('Compiled ' + file.path);
                        return true;
                    }
                }))
                .pipe(gulp.dest('.'));

That's unfortunate. I think you'll need to add the gulp-less/gulp-cache version to the key to be extra safe for this kind of thing. I've done this manually or by requiring the package.json and doing it programmatically.

We can't predict all the factors that will cause the cache to no longer be valid; we can make some good faith guesses and common sense defaults at best.

@jgable This will not solve the issue. The problem is persistent even when clearing the cache, using the plugin version within the key.

Created a PR which is also capable of tracking path changes withing the plugin (eg gulp-less), please have a look.

Fixed by #57 and published as 0.4.4