Skip to content

node-watch is not working recursive in Ubuntu under WSL #111

@intervalia

Description

@intervalia

WSL allows a user to run versions of Linux under windows.

When running Ubuntu 20.04.2 LTS in WSL I can not seem to get node-watch to do a recursive watch.
I am using node-watch v0.7.1

My code:

    watch(folder, {recursive: true}, (eventType, fname) => {

I have walked through the watch code and here is what I have found:

  1. You correctly identify that Ubuntu in WSL does not natively support recursive.
  2. Inside of Watcher.prototype.watchDirectory you walk the entire tree and call do the following with every folder
    var watcher = fs.watch(dir, opts);

    self.add(watcher, {
      type: 'dir',
      fpath: dir,
      options: options
    });

If I change something in the root folder then I get my callback called.
But I do not get the callback called for any of the sub folders.
I am trying to watch this folder: /mnt/d/Documents/Projects/omega/src and all subs.

I added the following code

  console.log(`wacthing the folder ${info.fpath}`);

Into your watch.js just before you call watcher.on('change', internalOnChange); so I can output the folder being watched and I get this list:

wacthing the folder /mnt/d/Documents/Projects/omega/src/api
wacthing the folder /mnt/d/Documents/Projects/omega/src/lib
wacthing the folder /mnt/d/Documents/Projects/omega/src/routes
wacthing the folder /mnt/d/Documents/Projects/omega/src/sharedViews
wacthing the folder /mnt/d/Documents/Projects/omega/src/static
wacthing the folder /mnt/d/Documents/Projects/omega/src/views
wacthing the folder /mnt/d/Documents/Projects/omega/src/api/account
wacthing the folder /mnt/d/Documents/Projects/omega/src/api/groups
wacthing the folder /mnt/d/Documents/Projects/omega/src/api/users
wacthing the folder /mnt/d/Documents/Projects/omega/src/lib/SessionManager
wacthing the folder /mnt/d/Documents/Projects/omega/src/lib/directoryService
wacthing the folder /mnt/d/Documents/Projects/omega/src/lib/test
wacthing the folder /mnt/d/Documents/Projects/omega/src/sharedViews/system
wacthing the folder /mnt/d/Documents/Projects/omega/src/static/brand
wacthing the folder /mnt/d/Documents/Projects/omega/src/static/css
wacthing the folder /mnt/d/Documents/Projects/omega/src/static/js
wacthing the folder /mnt/d/Documents/Projects/omega/src/views/dialogs
wacthing the folder /mnt/d/Documents/Projects/omega/src/api/groups/(groupName)
wacthing the folder /mnt/d/Documents/Projects/omega/src/api/users/(username)
wacthing the folder /mnt/d/Documents/Projects/omega/src/lib/directoryService/errors
wacthing the folder /mnt/d/Documents/Projects/omega/src/sharedViews/system/node
wacthing the folder /mnt/d/Documents/Projects/omega/src/static/brand/img
wacthing the folder /mnt/d/Documents/Projects/omega/src/static/js/polyfill

That is the full list of my folders.

I just don't get why I am not getting callbacks for sub folders and I do for the root folder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions