[Using gulp 3.9.0, gulp-cached 1.1.0, gulp-remember 0.3.0, gulp-rename 1.2.2]
We're using gulp as a build tool and gulp-cached together with gulp-remember to allow fast incremental rebuilds. Part of the files under build have to be moved to a different output directory and this has to happen in-stream (i.e. not in gulp.dest()), because we're zipping the results afterwards. We use gulp-rename for this.
However, when the build script is called multiple times (gulp.watch() for incremental rebuilds), then it seems to apply the gulp-rename transformation multiple times. It looks like gulp-remember is not actually outputting the files with the path it saw them last time, but with the path they got after the gulp-rename step.
I've narrowed the problem down to the following script:
var gulp = require('gulp');
var cached = require('gulp-cached');
var remember = require('gulp-remember');
var rename = require('gulp-rename');
function build() {
gulp.src("src/**")
.pipe(cached())
.pipe(remember())
.pipe(rename(function(path) {path.dirname = "resources/" + path.dirname;}))
.pipe(gulp.dest('build/'));
}
gulp.task('default', [], function() {
build();
build();
});
Running this on a source directory src with just one file "myfile.js" produces the output file:
/build/resources/resources/myfile.js
If the second call to build() is removed, it produces correctly
/build/resources/myfile.js
And if we insert a third call to build(), it produces
/build/resources/resources/resources/myfile.js
How can we fix this? Shouldn't gulp-remember output the files with the path they had when they passed through it last time before they have been processed further?