1.0.1 • Published 5 years ago

gulp-modifier v1.0.1

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
5 years ago

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 a String with the full contents of the file
  • path a String with the path to the file
  • file a vinyl File object representing the file being modified

Just return the new contents of the file from your function.

1.0.1

5 years ago

1.0.0

5 years ago