javascriptjquerynode.jsgulpgulp-if

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


Solution

  • 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;'));
    });