Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass parameters to change #5

Open
iiison opened this issue Mar 21, 2016 · 1 comment
Open

How to pass parameters to change #5

iiison opened this issue Mar 21, 2016 · 1 comment

Comments

@iiison
Copy link

iiison commented Mar 21, 2016

Is there way to pass parameters to performChange function from task. Such that

function performChange(content, someFlag) {
    return content.replace(/foo/g, someFlag);
}
gulp.task('change', function() {
    return gulp.src('src/*.html')
        .pipe(change(performChange)) // pass someFlag HOW?
        .pipe(gulp.dest('build/'))
});
@jeremyalan
Copy link

Here's one way you could achieve the same result:

function performChange(someFlag) {
    return function (content) {
        return content.replace(/foo/g, someFlag);
    }
}
gulp.task('change', function() {
    return gulp.src('src/*.html')
        .pipe(change(performChange('replace_text')))
        .pipe(gulp.dest('build/'))
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants