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

Many problems, help appreciated :) #154

Open
julien-f opened this issue Oct 9, 2014 · 4 comments
Open

Many problems, help appreciated :) #154

julien-f opened this issue Oct 9, 2014 · 4 comments

Comments

@julien-f
Copy link

julien-f commented Oct 9, 2014

Gaze install:

> npm i gaze
> gaze@0.6.4 install /tmp/tmp.0KceyZvfHl/node_modules/gaze
> node-gyp rebuild

make: Entering directory '/tmp/tmp.0KceyZvfHl/node_modules/gaze/build'
  CXX(target) Release/obj.target/pathwatcher/src/main.o
  CXX(target) Release/obj.target/pathwatcher/src/common.o
  CXX(target) Release/obj.target/pathwatcher/src/handle_map.o
../src/handle_map.cc: In member function ‘bool HandleMap::Erase(WatcherHandle)’:
../src/handle_map.cc:41:26: warning: ‘void NanDispose(v8::Persistent<S>&) [with T = v8::Value]’ is deprecated (declared at ../node_modules/nan/nan.h:612) [-Wdeprecated-declarations]
   NanDispose(iter->second); // Deprecated, use NanDisposePersistent when v0.12 lands
                          ^
../src/handle_map.cc: In member function ‘void HandleMap::Clear()’:
../src/handle_map.cc:48:28: warning: ‘void NanDispose(v8::Persistent<S>&) [with T = v8::Value]’ is deprecated (declared at ../node_modules/nan/nan.h:612) [-Wdeprecated-declarations]
     NanDispose(iter->second); // Deprecated, use NanDisposePersistent when v0.12 lands
                            ^
  CXX(target) Release/obj.target/pathwatcher/src/pathwatcher_linux.o
  SOLINK_MODULE(target) Release/obj.target/pathwatcher.node
  SOLINK_MODULE(target) Release/obj.target/pathwatcher.node: Finished
  COPY Release/pathwatcher.node
make: Leaving directory '/tmp/tmp.0KceyZvfHl/node_modules/gaze/build'
gaze@0.6.4 node_modules/gaze
├── bindings@1.2.1
├── absolute-path@0.0.0
├── nextback@0.1.0
├── graceful-fs@2.0.3
├── nan@0.8.0
└── globule@0.2.0 (lodash@2.4.1, minimatch@0.2.14, glob@3.2.11)

Test code:

require('gaze')('/tmp', function (error) {
  if (error) {
    console.error(error);
    return;
  }

  this.watched(function (error, files) {
    if (error) {
      console.log(error);
      return;
    }
    console.log('watched:', files);
  });

  this.on('added', function (file) {
    console.log('added', file);
  });
  this.on('changed', function (file) {
    console.log('changed', file);
  });
  this.on('deleted', function (file) {
    console.log('deleted', file);
  });
  this.on('renamed', function (file) {
    console.log('renamed', file);
  });
});
  1. With this setup, no file creation, deletion, renaming or change in the /tmp directory is picked up.
  2. I suspect it's because I need to use the '/tmp/*' pattern to indicate I want to watch files inside.
    But now, if file change and deletion is correctly detected, addition and renaming still does not work.
  3. Maybe it is because the parent directory should also be watched to detect new files so I set ['/tmp', '/tmp/*'] as the pattern. But I still get the same behavior 😢
  4. I have seen in other issues that you suggest to use the cwd options so now I use '*' for the pattern and '/tmp' as cwd. Now we're getting somwhere! The creation, change and deletion work but still no luck for renaming, I only get a delete event :/
    Another problem is that when I delete all files (rm -f *) only the deletion of the first one is picked up.

What am I doing wrong?

@shama
Copy link
Owner

shama commented Oct 9, 2014

gaze works on file patterns rather than file paths, so you're correct about using the cwd option if you're targeting files in a different cwd than process.cwd().

You should get a rename event.

  • Which version of node and OS are you on?
  • Are you doing gaze('*', { cwd: '/tmp' }, function() { /* ... */ })?

@julien-f
Copy link
Author

I have to use cwd because absolute path patterns are not supported?

I am on Debian Jessie and I use Node v0.10.32.

@julien-f
Copy link
Author

And yep I am doing gaze('*', { cwd: '/tmp' }, …).

@julien-f
Copy link
Author

And after some time, I get the following error:

/tmp/tmp.0KceyZvfHl/node_modules/gaze/lib/helper.js:101
  if (!arr.length) {
          ^
TypeError: Cannot read property 'length' of undefined
    at Object.forEachSeries (/tmp/tmp.0KceyZvfHl/node_modules/gaze/lib/helper.js:101:11)
    at /tmp/tmp.0KceyZvfHl/node_modules/gaze/lib/gaze.js:298:12
    at ReaddirReq.Req.done (/tmp/tmp.0KceyZvfHl/node_modules/gaze/node_modules/graceful-fs/graceful-fs.js:143:5)
    at ReaddirReq.done (/tmp/tmp.0KceyZvfHl/node_modules/gaze/node_modules/graceful-fs/graceful-fs.js:90:22)
    at Object.oncomplete (fs.js:107:15)

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