Search code examples
gitgulpgulp-watch

How can a gulp task know if a gulp.watch task is running?


I have a gulp git task that does a checkout, thus changes the current working dir.

I also have gulp watch tasks that recompile changed files.

I do NOT want to run the git task if any watch task is running .. it would recompile the files in the new branch.

Is there a way to detect if a gulp watch task is running? If so I can simply exit the git task with a warning message.


Solution

  • You could use the gulp-if plugin for this

    Create a variable isWatching for instance, and when running your watch task, set it to true Then, in your task that runs git you can do: if(!isWatching, runGit), where runGit would be a function that executes your git task or whatever


    PasteBin Example (for color coding)