-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
feat: fs events #3452
feat: fs events #3452
Conversation
After more digging I'm not sure fs events can solved elegantly at the moment. There's no way to turn this sync API into async one. Once we land Tokio 0.2 there's |
Not sure how to test it yet... Docs state that contents of event depend on the platform. Example output for
Also serialization output is really questionable in my opinion... |
I think a platform dependent test would be fine. Probably a custom integration test would be the best way to test this. Create a temp dir, add file, touch it, etc - check events are issued in JS. |
Test case: const testDir = await Deno.makeTempDir();
const file1 = testDir + "/file1.txt";
const file2 = testDir + "/file2.txt";
const watcher = Deno.watch(testDir, { recursive: true });
// start capturing events in the background
await Deno.writeFile(file1, new Uint8Array([0, 1, 2]));
await Deno.writeFile(file2, new Uint8Array([0, 1, 2]));
await Deno.remove(file1);
await Deno.rename(file2, file1);
await Deno.chmod(file1, 0o666);
const f = await Deno.open(file1);
f.close();
setTimeout(() => {
watcher.close();
}, 750); ubuntu:
macOS
Windows
|
feel free to make the test sloppy - i don't think nailing down the exact order is important at this stage |
Sure, what about return type from watcher? What you see above is what |
This is getting stale; the only thing left to do in it is providing some unified interface between different OSes (see #3452 (comment)). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally working!
|
||
export function fsEvents( | ||
paths: string | string[], | ||
options = { recursive: true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be written as
{
recursive = true
}: FsEventsOptions = {}
for full robustness.
Deno.watch feature is added at this time in 0.35 version? |
Prototype for file watching.
Uses https://docs.rs/notify/5.0.0-pre.2/notify/index.html
I used some code from @jcao219