Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watch only fires when patterns match #520

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "grunt-contrib-watch",
"name": "@medic/grunt-contrib-watch",
"description": "Run predefined tasks whenever watched file patterns are added, changed or deleted",
"version": "1.0.0",
"version": "1.0.1",
"author": {
"name": "Grunt Team",
"url": "http://gruntjs.com/"
},
"repository": "gruntjs/grunt-contrib-watch",
"repository": "scdf/grunt-contrib-watch",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
Expand Down
6 changes: 6 additions & 0 deletions tasks/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
var path = require('path');
var Gaze = require('gaze').Gaze;
var _ = require('lodash');
var globule = require('globule');
var waiting = 'Waiting...';
var changedFiles = Object.create(null);
var watchers = [];
Expand Down Expand Up @@ -147,6 +148,11 @@ module.exports = function(grunt) {
return;
}

// Skip non matching hits caused by Gaze on some systems
if (!globule.isMatch(patterns, filepath)) {
return;
}

// If Gruntfile.js changed, reload self task
if (target.options.reload || /gruntfile\.(js|coffee)/i.test(filepath)) {
taskrun.reload = true;
Expand Down