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

Globstar not working when there is a directory after it #240

Closed
lboynton opened this issue Feb 25, 2015 · 3 comments
Closed

Globstar not working when there is a directory after it #240

lboynton opened this issue Feb 25, 2015 · 3 comments

Comments

@lboynton
Copy link

Hopefully I've narrowed down this issue enough to make sense.

Here is a test app (test.js):

require('chokidar').watch('/tmp/a/**/d/*.txt', {
  persistent: true,
}).on('all', function(event, path) {
  console.log(event, path);
}).on('ready', function() {
  console.log('ready');
})

Setting up environment:

$ mkdir -p /tmp/a/b/c/d
$ touch /tmp/a/b/c/d/e.txt
$ node test.js

Expected output:

add /tmp/a/b/c/d/e.txt
ready

Actual output:

ready

It is not picking up the file because the globstar is only matching one level of directories, not one or more as I expected. I've tested this in minimatch and anymatch and these work as expected.

In file test2.js:

var anymatch = require('anymatch');
console.log(anymatch('/tmp/a/**/d/*.txt', '/tmp/a/b/c/d/e.txt'));
$ node test2.js
true

Is this a bug? Thanks!

@es128
Copy link
Contributor

es128 commented Feb 26, 2015

Yes, it's a bug. However it only applies to the initial readdirp scan. If you touch /tmp/a/b/c/d/e.txt again while the watcher is running, events do get emitted.

This is likely related to #239, in that I suspect they have the same underlying cause.

@lboynton
Copy link
Author

Actually, when I touch the file with touch /tmp/a/b/c/d/e.txt it does not emit an event. However, if I do:

mkdir a/d
touch a/d/e.txt

I do get an add /tmp/a/d/e.txt.

Sorry, I forgot to add environment info to my issue:

OS: Ubuntu 14.04.2
Node: v0.10.25
npm versions:

/tmp
└─┬ chokidar@1.0.0-rc3
  ├─┬ anymatch@1.1.0
  │ └─┬ minimatch@1.0.0
  │   ├── lru-cache@2.5.0
  │   └── sigmund@1.0.0
  ├── async-each@0.1.6
  ├─┬ glob-parent@1.0.0
  │ └── is-glob@0.3.0
  ├─┬ is-binary-path@1.0.0
  │ └── binary-extensions@1.3.0
  └─┬ readdirp@1.3.0
    ├── graceful-fs@2.0.3
    ├─┬ minimatch@0.2.14
    │ ├── lru-cache@2.5.0
    │ └── sigmund@1.0.0
    └─┬ readable-stream@1.0.33
      ├── core-util-is@1.0.1
      ├── inherits@2.0.1
      ├── isarray@0.0.1
      └── string_decoder@0.10.31

@lboynton
Copy link
Author

lboynton commented Mar 5, 2015

Thanks @es128, this has solved my issue! 😃

taratatach pushed a commit to taratatach/chokidar that referenced this issue Oct 2, 2023
Correctly indicate which node versions support N-API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants