Ask
Ask

Reputation: 3746

gulp-If. How to check if js file contains specific property?

I am using gulp.js. But I want to add a condition that if request.debug = true; in any of my js file then gulp task should fail. I have found gulp-if and gulp-fail that I can use for this purpose but I don't know that how can I check the specific condition? Thanks

Upvotes: 0

Views: 904

Answers (1)

Stephen S
Stephen S

Reputation: 3994

You could use the gulp-contains module. If the condition provided to the contains function is true, an error is thrown.

gulp.task('default', function () {
    gulp.src('src/**/*.js')
        .pipe(contains('request.debug = true;'));
});

Upvotes: 1

Related Questions