gulp-modifier
v1.0.1
Published
Modify the contents of files in a gulp stream with a user provided function.
Downloads
5
Readme
gulp-modifier
Modify the contents of files in a gulp stream with an arbitrary modifier function.
const gulp = require('gulp');
const gulpModifier = require('gulp-modifier');
function modify() {
return gulp.src('src/files/**')
.pipe(gulpModifier((contents, path) => {
let newContents = contents.replace('lame', 'awesome');
newContents += path;
return newContents.trim();
}))
.pipe(gulp.dest('./dist/files/'));
}
exports.modify = modify;
This is based on gulp-modify and gulp-modify-file both of which seem to be no longer maintained or not up to speed with gulp 4 methodology.
The modifier function you pass in will get the following arguments:
contents
aString
with the full contents of the filepath
aString
with the path to the filefile
a vinylFile
object representing the file being modified
Just return the new contents of the file from your function.