watchexec/watchexec

Question: How to use the 3.0 filters?

SuperCuber opened this issue · 4 comments

I use the watchexec library 2.0 in my project like so
https://github.com/SuperCuber/dotter/blob/ec72e2a322a960bebb78d2c612291c0451fdd0aa/src/watch.rs

I'd like some help translating it to 3.0 - I see now there's no more filter objects and I need to implement it myself? This is what I have so far, but I'm running into issues with comparing relative vs absolute paths (especially on windows, canonicalize returns weird paths that start with \\\?\

Is there a recommended solution for the exact and glob filter equivalents?

The filter implementations ("filterers") are in external crates (since the 2.0.0 stable release), so you're looking to change

use watchexec::filter::tagged::{Filter, Matcher, Op, Pattern, TaggedFilterer};

to

use watchexec_filterer_tagged::{Filter, Matcher, Op, Pattern, TaggedFilterer};

and

[dependencies]
watchexec-filterer-tagged = "1.0.0"

Thanks, that's extremely helpful!

Another question, before I had

action.outcome(Outcome::if_running(Outcome::DoNothing, Outcome::Start));

I don't remember whether I did it for some specific reason.

Now I simply return action. Is this equivalent behavior? Or do I need to pay attention to something here?

Given your code, and that you're not starting a command at all, I'd say that maybe that was copied from an example. I can't think of a reason to do anything else than returning action (doing nothing) here in your context.

I see, thanks :)