gulp-data icon indicating copy to clipboard operation
gulp-data copied to clipboard

Please provide a cache option

Open bolord opened this issue 11 years ago • 2 comments

Hello! I'm using this plugin to add some data for gulp-swig.

This plugin has a cache for readed files? Why when I changed data files, same content in return like first time?

bolord avatar Feb 02 '15 15:02 bolord

I found answer, it's require() cache.

My solution:

gulp.task('json-test', function() {
  return gulp.src('./examples/test1.html')
    .pipe(data(function(file) {
      var json = './examples/' + path.basename(file.path) + '.json';
      delete require.cache[require.resolve(json)];
      return require(json);
    }))
    .pipe(swig())
    .pipe(gulp.dest('build'));
});

bolord avatar Feb 02 '15 15:02 bolord

@bolord thanks for coming back and posting your solution, as I was looking a way to clean the cache on gulp-data.

maniqui avatar Jun 25 '15 19:06 maniqui