fs.watch and absolute path to directory

100 views
Skip to first unread message

Joran Dirk Greef

unread,
Sep 8, 2014, 3:13:23 AM9/8/14
to nod...@googlegroups.com
I have been trying out fs.watch on Mac and noticed that providing a relative path to fs.watch works, but providing an absolute path does not?

Joran Dirk Greef

unread,
Sep 9, 2014, 2:10:07 AM9/9/14
to nod...@googlegroups.com
Since then I found that providing an absolute path to fs.watch on Mac works if the path is outside (not a descendant of) the original current working directory for the process.

If the path is inside or equal to the original current working directory of the process, then providing an absolute path does not work (fs.watch returns no events for changes). In this case, providing the shortest possible relative path will work, or "." for the current working directory.

Using process.chdir makes no difference, it's the original current working directory that is taken into account.

Also, it seems like fs.watch on Mac on a directory always includes changes in subdirectories regardless of whether recursive is true or false.
Reply all
Reply to author
Forward
0 new messages