@@ -3,8 +3,9 @@ use std::{
3
3
sync:: Arc ,
4
4
} ;
5
5
6
- use anyhow:: bail ;
6
+ use anyhow:: Context ;
7
7
use async_trait:: async_trait;
8
+ use spin_common:: ui:: quoted_path;
8
9
use spin_manifest:: schema:: v2;
9
10
10
11
#[ async_trait]
@@ -34,7 +35,7 @@ impl FilterFactory for ArtifactFilterFactory {
34
35
manifest : & v2:: AppManifest ,
35
36
) -> anyhow:: Result < Arc < watchexec_filterer_globset:: GlobsetFilterer > > {
36
37
let manifest_glob = if self . skip_build {
37
- vec ! [ stringize_path ( manifest_file) ?]
38
+ vec ! [ manifest_path_to_watch ( manifest_file) ?]
38
39
} else {
39
40
vec ! [ ] // In this case, manifest changes trigger a rebuild, which will poke the uppificator anyway
40
41
} ;
@@ -95,7 +96,7 @@ impl FilterFactory for BuildFilterFactory {
95
96
manifest_dir : & Path ,
96
97
manifest : & v2:: AppManifest ,
97
98
) -> anyhow:: Result < Arc < watchexec_filterer_globset:: GlobsetFilterer > > {
98
- let manifest_glob = vec ! [ stringize_path ( manifest_file) ?] ;
99
+ let manifest_glob = vec ! [ manifest_path_to_watch ( manifest_file) ?] ;
99
100
let src_globs = manifest
100
101
. components
101
102
. iter ( )
@@ -152,7 +153,7 @@ impl FilterFactory for ManifestFilterFactory {
152
153
manifest_dir : & Path ,
153
154
_: & v2:: AppManifest ,
154
155
) -> anyhow:: Result < Arc < watchexec_filterer_globset:: GlobsetFilterer > > {
155
- let manifest_glob = stringize_path ( manifest_file) ?;
156
+ let manifest_glob = manifest_path_to_watch ( manifest_file) ?;
156
157
157
158
let filterer = watchexec_filterer_globset:: GlobsetFilterer :: new (
158
159
manifest_dir,
@@ -167,11 +168,13 @@ impl FilterFactory for ManifestFilterFactory {
167
168
}
168
169
}
169
170
170
- fn stringize_path ( path : & Path ) -> anyhow:: Result < String > {
171
- match path. to_str ( ) {
172
- Some ( s) => Ok ( s. to_owned ( ) ) ,
173
- None => bail ! ( "Can't represent path {} as string" , path. display( ) ) ,
174
- }
171
+ // Although manifest dir must be absolute, and most things are safer with abs
172
+ // file paths, the manifest _path_ for the watchers must be relative to manifest dir
173
+ fn manifest_path_to_watch ( path : & Path ) -> anyhow:: Result < String > {
174
+ let rel_path = path
175
+ . file_name ( )
176
+ . with_context ( || format ! ( "resolved manifest {} has no filename" , quoted_path( path) ) ) ?;
177
+ Ok ( rel_path. to_string_lossy ( ) . to_string ( ) )
175
178
}
176
179
177
180
fn standard_ignores ( ) -> Vec < ( String , Option < PathBuf > ) > {
0 commit comments