question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Gulp watch fire task only on added or deleted

See original GitHub issue

Is there a way to only trigger a task upon a particular set of event types. e.g. added or deleted?

gulp.watch(`/path/to/new/files**/*`, (event) => {
  if (event.type === 'added' || event.type === 'deleted') {
    // fire some gulp task
  }
});

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
yasinkocakcommented, Feb 8, 2016

On Gulp 3.8 and 3.9 is only triggering ‘changed’ and ‘deleted’ files if your source start with ‘./’ without ‘./’ triggering also ‘added’.

Gulp 4.0 not tested.

Using Mac OSX El Capitan

var gulp = require('gulp');

gulp.task('default', function () {
  gulp.watch('templates/**/*.html', function (event) {
    console.log(event);
  });
});
0reactions
phatedcommented, Feb 8, 2016

Chalking this up to #651 for 3.9 - However, I think you can use the returned watcher to listen on events, I’m not sure how accurate they are due to all the other problems. In gulp 4, you can use the returned watcher to listen for all events that chokidar emits.

Read more comments on GitHub >

github_iconTop Results From Across the Web

gulp.watch trigger only when files are added or deleted but not ...
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/**/ ...
Read more >
watch() - gulp.js
name type default ignoreInitial boolean true delay number 200 queue boolean true
Read more >
Building a Gulp workflow wrapped around Jekyll
An attempt at adding more dynamism to Jekyll via a workflow revamp using Gulp as a task runner and BrowserSync as a local...
Read more >
Browsersync + Gulp.js
Browsersync makes your browser testing workflow faster by synchronising URLs, interactions and code changes across multiple devices.
Read more >
How To Build And Develop Websites With Gulp
In other words, if you run a task that requires only two plugins, it won't load all of the plugins that the other...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found