facebook / watchman

Watches files and records, or triggers actions, when they change.
https://facebook.github.io/watchman/
MIT License
12.57k stars 986 forks source link

[Question]: Examples to pass config arguments to `watchman` node API #1075

Closed JayaKrishnaNamburu closed 1 year ago

JayaKrishnaNamburu commented 1 year ago

I am using the node-api for watching some files and running commands. https://facebook.github.io/watchman/docs/nodejs.html#initiating-a-watch

But, is there a way to pass arguments like ignore_vsc etc for the Node API ?. Or we just need to follow watchmanconfig.json under /etc/ folder ?

Or, are there commands to disable certain capability for watchman ?

And one more, if we disable vcs. Watchman will not trigger for changes uder .git folder right ?

Sorry, i wanted to post under GH - Discussions. But, looks like it is not enabled for the repo. And i couldn't find much examples

xavierd commented 1 year ago

As documented at: https://facebook.github.io/watchman/docs/config.html#resolution--scoping, the ignore_vcs is read from the .watchmanconfig at the root of the repository, it cannot be changed with the Node API (or any other API for that matter).

Capabilities cannot be disabled, would you mind describing why you'd want some to be disabled?

And one more, if we disable vcs. Watchman will not trigger for changes uder .git folder right ?

Do you mean setting ignore_vcs to an empty list?

JayaKrishnaNamburu commented 1 year ago

So, my use case ws to write a abstraction to watch for specific files in a monorepo and then build those specific packages again when changes. But when using watchman with node-api.

For every .git/ change i do, it tends to trigger my watchers. But, if i set ignore_vcs in etc/watchman.json to true. will it still trigger for changes in .git folder ? Is there any way that i can ingote .git folder changes to trigger my watchers ?

xavierd commented 1 year ago

In your query you should be able to have an expression that ignores changes to the .git directory with https://facebook.github.io/watchman/docs/expr/dirname.html.

JayaKrishnaNamburu commented 1 year ago

Hey, thanks for the information. Got what i am looking for. Can i close the issue now 😄 👍

gajus commented 1 year ago

This issue didn't answer the original question – How do I pass arguments to Node.js API?