@@ -19,6 +19,7 @@ use std::{
1919} ;
2020
2121use anyhow:: Context ;
22+ use glob:: glob;
2223use heck:: ToKebabCase ;
2324use ignore:: gitignore:: { Gitignore , GitignoreBuilder } ;
2425use log:: { debug, error, info} ;
@@ -334,6 +335,18 @@ fn lookup<F: FnMut(FileType, PathBuf)>(dir: &Path, mut f: F) {
334335 }
335336}
336337
338+ // Copied from https://github.com/rust-lang/cargo/blob/69255bb10de7f74511b5cef900a9d102247b6029/src/cargo/core/workspace.rs#L665
339+ fn expand_member_path ( path : & Path ) -> crate :: Result < Vec < PathBuf > > {
340+ let Some ( path) = path. to_str ( ) else {
341+ return Err ( anyhow:: anyhow!( "path is not UTF-8 compatible" ) ) ;
342+ } ;
343+ let res = glob ( path) . with_context ( || format ! ( "could not parse pattern `{}`" , & path) ) ?;
344+ let res = res
345+ . map ( |p| p. with_context ( || format ! ( "unable to match path to pattern `{}`" , & path) ) )
346+ . collect :: < Result < Vec < _ > , _ > > ( ) ?;
347+ Ok ( res)
348+ }
349+
337350impl Rust {
338351 fn run_dev < F : Fn ( ExitStatus , ExitReason ) + Send + Sync + ' static > (
339352 & mut self ,
@@ -420,7 +433,21 @@ impl Rust {
420433 . unwrap_or_else ( || vec ! [ tauri_path] )
421434 } ;
422435
436+ let watch_folders = watch_folders
437+ . into_iter ( )
438+ . flat_map ( |p| {
439+ match expand_member_path ( & p) {
440+ Ok ( p) => p,
441+ Err ( err) => {
442+ // If this fails cargo itself should fail too. But we still try to keep going with the unexpanded path.
443+ error ! ( "Error watching {}: {}" , p. display( ) , err. to_string( ) ) ;
444+ vec ! [ p]
445+ }
446+ }
447+ } )
448+ . collect :: < Vec < _ > > ( ) ;
423449 let watch_folders = watch_folders. iter ( ) . map ( Path :: new) . collect :: < Vec < _ > > ( ) ;
450+
424451 let common_ancestor = common_path:: common_path_all ( watch_folders. clone ( ) ) . unwrap ( ) ;
425452 let ignore_matcher = build_ignore_matcher ( & common_ancestor) ;
426453
0 commit comments