Skip to content

Watch directory for new files #116

Description

@jacobalberty

the memfs.watch() function doesn't seem to work on directories. The following code works as expected:

var fs = require('fs');
if (fs.vol) fs.vol.fromJSON({ '/tmp': {}});
var fswatcher = fs.watch('/tmp', console.log);
fs.writeFileSync('/tmp/test.file', 'test data');
fs.unlinkSync('/tmp/test.file');
setTimeout(() => {fswatcher.close()}, 500);

Producing the output:

rename test.file
change test.file
rename test.file

but change it to use memfs instead::

var fs = require('memfs');
if (fs.vol) fs.vol.fromJSON({ '/tmp': {}});
var fswatcher = fs.watch('/tmp', console.log);
fs.writeFileSync('/tmp/test.file', 'test data');
fs.unlinkSync('/tmp/test.file');
setTimeout(() => {fswatcher.close()}, 500);

and I get no output.

EDIT: Changed the test code to be a little simpler and make the two cases much closer to each other with only a single line change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions