🚀 Socket Launch Week 🚀 Day 5: Introducing Socket Fix.Learn More
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-change

allow file content manipulations

1.0.2
latest
Version published
Maintainers
1
Created

gulp-change

File content change utility for GulpJS.

Allow to easily alter the content of a Gulp files stream with a sync/async callback

npm install gulp-change

Sync Usage

var gulp = require('gulp');
var change = require('change');

function performChange(content) {
    return content.replace(/foo/g, 'FOO');
}

gulp.task('change', function() {
    return gulp.src('src/*.html')
        .pipe(change(performChange))
        .pipe(gulp.dest('build/'))
});

Async Usage

var gulp = require('gulp');
var change = require('change');

function performChange(content, done) {
    content.replace(/foo/g, 'FOO');
    done(null, content);
}

gulp.task('change', function() {
    return gulp.src('src/*.html')
        .pipe(change(performChange))
        .pipe(gulp.dest('build/'))
});

Callback Context

The callback receive a custom context (this) populated with:

file

original file object from Gulp' stream

fname

file name

originalContent

original file content

FAQs

Package last updated on 01 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts