gulp icon indicating copy to clipboard operation
gulp copied to clipboard

gulp.watch reports ignored files

Open bjg2 opened this issue 4 years ago • 3 comments

What were you expecting to happen? Not to get watch triggered on the files I ignored (I ignored "!other_project/node_modules/**/*" and I get triggered on "other_project/node_modules/.bin/uuid").

What actually happened? Watch is getting triggered on change in "other_project/node_modules/.bin/uuid".

Please post a sample of your gulpfile (preferably reduced to just the bit that's not working) There is whole repro here. Clone it, do npm install and node test.js.

What version of gulp are you using? 4.0.2

What versions of npm and node are you using? npm 6.4.1 node 8.15.1 os is ubuntu 18.04.3 LTS

bjg2 avatar Aug 08 '19 12:08 bjg2

By default, Gulp's micromatch matcher ignores dotfiles, and your path includes /.bin. Not sure if it's possible to disable that behavior from Gulp, though.

rgroothuijsen avatar Nov 11 '19 22:11 rgroothuijsen

Your link goes to here where it contain gulp watch.

This is the same problem as my.

Even if I use the most simple code like this the problem still exists and very easy to see.


'use strict';


const {series, parallel, src, dest, watch} = require('gulp');
const print = require('gulp-print').default;

const patterns = [
    './**',
    '!./node_modules',
    '!./node_modules/**',
    '!./tests',
    '!./tests/**',
];
const srcPath = 'D:/wwwroot/_test/gulp-test';
const destPath = 'D:/wwwroot/_test/gulp-dest';


function doCopy(cb) {
    return src(patterns, {
        allowEmpty: true,
        base: srcPath,
        cwd: srcPath
    })
    .pipe(print())
    .pipe(dest(destPath))
}


function doWatch(cb) {
    const watcher = watch(patterns, {
        base: srcPath,
        cwd: srcPath,
        events: 'all'
    });
    watcher.on('all', (event, filepath) => {
        console.log(event, filepath);
    });
    cb();
}


// exports ==================================
exports.default = series(
    doCopy
);

exports.watch = series(doWatch);

Create folder that is filtered out just like your other_project or tests in my example and then create a text file. The text file is ready to copy to destination on create/modify.

They did not even try but keep asking something unrelated.

ve3 avatar Jun 29 '22 19:06 ve3

This issue gets fixed by glob-watcher version 6, per my testing. So it will probably be fixed without work/at v5 release.

pwall2222 avatar Jun 05 '23 20:06 pwall2222