0

I want to fire off a task only when files are added or deleted but not changed.

I have the watch

gulp.watch(['src/App/**/*.js', 'src/**/*.css'], ['inject']);

But this triggers an inject every time I change a file, I only want to trigger an inject when I add or delete a file. I can't seem to find any way to do this.

1 Answer 1

0
gulp.task('watch',function(){
    gulp.watch(['src/App/**/*.js', 'src/**/*.css'],function(event){
        if(event.type === 'added' || event.type === 'deleted'){
            console.log('file was added or deleted!');
        }   
    })
})

If you want to run tasks registered only when watched file are added or deleted. such as:

gulp.watch(['src/App/**/*.js', 'src/**/*.css'], ['inject']);

As far as I know, there is no way to achieve this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.