facebook / watchman

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

Watchman ignores platform-specific path separators in `dirname` expressions #1146

Open leops opened 1 year ago

leops commented 1 year ago

Issuing a file query using backward-slashes as path separators like ["dirname", "app\src"] does not return any result, but using forward-slashes like ["dirname", "app/src"] does work as expected.

This issue is related to facebook/relay#4339: the Relay Compiler generates file queries of the form ["allof", ["dirname", "app\src"], ["suffix", "js"]] in order to find all source files in the project. The dirname value is generated from a Rust Path that uses the platform-specific path separator, so backward-slashes on Windows, which makes the compiler silently fail as Watchman does not return any source file matching the query. Normalizing all path separators to forward-slashes in Watchman queries fixes the issue for the Relay Compiler, but it might be a better solution to change this behavior at the Watchman level instead.