gulp watch race condition, it keeps on changing my file

4 views
Skip to first unread message

Muhammad Wasim

unread,
May 26, 2017, 12:51:23ā€ÆPM5/26/17
to nod...@googlegroups.com

Hi,

I am trying to write a gulp build process but i am stuck in race condition due to watch. I don't know how to overcome this problem.

I am trying to watch html/js/ts changes, and using linker to insert script tags after compiling my code. When linker modifies html file, watch re-runs the whole build process. Don't know how to solve this.

gulp.task('link',function(){
   gulp.src('./app/index.html')
    .pipe(linker({
        scripts: [ "./app/js/*/**.js ",'!./app/js/browserify/*.js'],
        startTag: '<!--SCRIPTS-->',
        endTag: '<!--SCRIPTS END-->',
        fileTmpl: '<script src="%s"></script>',
        appRoot: './app'
    }))
    .pipe(gulp.dest('./app')).pipe(livereload());
})


gulp.task('watch', function() {
    // watch many files
    livereload.listen();
    gulp.watch(['./app/**/*.html','./app/**/*.ts','./app/js/browserify/*.js']).on('change',function () {
        return runSequence(['clean'],
            ['cleanbundle'],
            ['compile'],
            ['lint'],
            ['browserify'],
            ['link']);
    });
});

Regards,
Wasim
Reply all
Reply to author
Forward
0 new messages