gulp-data
gulp-data copied to clipboard
A way to ignore if file doesnt exist
I want to try to load the json file and if it doesnt exists just ignore and keep going.
Advice?
Try this...
gulp.task('json-test', function() {
return gulp.src('./examples/test1.html')
.pipe(data(function(file) {
var path = './examples/' + path.basename(file.path) + '.json';
return (fs.existsSync(path)) ? require(path) : {};
}))
.pipe(swig())
.pipe(gulp.dest('build'));
});