Skip to content

gulp.watch not works if watched glob contains Japanese characters folder name #2153

Closed

Description

@aruku7230
  • gulp: 4.00
  • node: 8.9.4
  • npm: 5.8.0
  • OS: macOS 10.12.6

gulpfile.json

const gulp = require('gulp');
const watchGlob = 'folder/**/*';

gulp.task('test', () => {
    gulp.watch(watchGlob, (done) => { done() })
            .on('change', (path) => {
                console.log(`File ${path} changed.`);
            });
});

run test task and change folder/foo file
result output is:

Starting 'test'...
File folder/foo changed.
Starting ''...
Finished '' after 1.45 ms

change watchGlob

const watchGlob = 'フォルダ/**/*';

run test task and change フォルダ/foo file.
result output is:

Starting 'test'...

Activity

  1. rgroothuijsen commented on Apr 30, 2018

    @rgroothuijsen

    This is most likely a bug in one of the underlying libraries gulp uses for file watching. Interestingly, the フォルダ/** and フォルダ/* glob patterns do react as expected, as does changing a file like フォルダ/foo/bar.

  2. yocontra commented on Apr 30, 2018

    @yocontra
    Member

    Can you test it with https://github.com/paulmillr/chokidar directly and see if you can reproduce it? If so the issue goes there, if not we can look into it here.

    Thanks for the report.

  3. aruku7230 commented on May 12, 2018

    @aruku7230
    Author

    Reproduce it use chokidar. It's a issue with chokidar.

    const watchGlob = 'フォルダ/**/*';
    
    gulp.task('test', () => {
        const chokidar = require('chokidar');
        chokidar.watch(watchGlob, (done) => { done() })
                .on('change', (path) => {
                    console.log(`File ${path} changed.`);
                });
    });
  4. sttk commented on May 12, 2018

    @sttk
    Contributor

    This issue is due to micromatch which is used in chokidar.

  5. MasatoMakino commented on Aug 23, 2018

    @MasatoMakino

    I think it related to NFD filename on macOSX.
    NFD's "ダ" is "タ" + " " ".
    NFD's "ダ" chrcode deffer from NFC's "ダ" chrcode.

  6. phated commented on Nov 14, 2018

    @phated
    Member

    We've just added a Bug Bounty of $50 on this issue if anyone wants to solve it.

  7. pe8ter commented on Nov 18, 2018

    @pe8ter

    I think I have the issue narrowed down to a RegExp in the nanomatch package. This issue is not restricted to Japanese, but to any directory that doesn't end in 0-9, a-z, A-Z, or _. I opened micromatch/nanomatch#18.

  8. jonschlinkert commented on Nov 18, 2018

    @jonschlinkert

    but to any directory that doesn't end in 0-9, a-z, A-Z, or _.

    The regex was written to only match valid path characters, but this clearly was shortsighted and insensitive to non-English languages. I will get that fixed.

  9. jonschlinkert commented on Nov 18, 2018

    @jonschlinkert

    I'd also happily accept a PR to fix it if someone wants to earn the bounty. Just let me know.

  10. phated commented on Apr 20, 2019

    @phated
    Member

    This is actually going to have to wait until gulp 5.0 to be fixed because it relies on a rewrite of the micromatch parser (which only made sense to be released as a major), and that version will only be used in a version of chokidar that doesn't support all versions of nodejs we support in 4.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugupstreamIssues that need to be fixed upstream

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions