@@ -22,9 +22,8 @@ use std::sync::mpsc::channel;
22
22
#[ tokio:: main]
23
23
async fn main ( ) {
24
24
// In development, we'll test in the `basic` example
25
- if cfg ! ( debug_assertions) {
26
- let example_to_test =
27
- env:: var ( "TEST_EXAMPLE" ) . unwrap_or_else ( |_| "../../examples/basic" . to_string ( ) ) ;
25
+ if cfg ! ( debug_assertions) && env:: var ( "TEST_EXAMPLE" ) . is_ok ( ) {
26
+ let example_to_test = env:: var ( "TEST_EXAMPLE" ) . unwrap ( ) ;
28
27
env:: set_current_dir ( example_to_test) . unwrap ( ) ;
29
28
}
30
29
let exit_code = real_main ( ) . await ;
@@ -162,10 +161,14 @@ async fn core(dir: PathBuf) -> Result<i32, Error> {
162
161
// This will be updated every time we re-create the process
163
162
// We spawn it as a process group, whcih means signals go to grandchild processes as well, which means hot reloading
164
163
// can actually work!
165
- let mut child = Command :: new ( & bin_name)
164
+ let mut child = Command :: new ( & bin_name) ;
165
+ let child = child
166
166
. args ( & args)
167
167
. env ( "PERSEUS_WATCHING_PROHIBITED" , "true" )
168
- . env ( "PERSEUS_USE_RELOAD_SERVER" , "true" ) // This is for internal use ONLY
168
+ . env ( "PERSEUS_USE_RELOAD_SERVER" , "true" ) ; // This is for internal use ONLY
169
+ #[ cfg( debug_assertions) ]
170
+ let child = child. env_remove ( "TEST_EXAMPLE" ) ; // We want to use the current directory in development
171
+ let mut child = child
169
172
. group_spawn ( )
170
173
. map_err ( |err| WatchError :: SpawnSelfFailed { source : err } ) ?;
171
174
@@ -177,10 +180,14 @@ async fn core(dir: PathBuf) -> Result<i32, Error> {
177
180
// This gracefully kills the process in the sense that it kills it and all its children
178
181
let _ = child. kill ( ) ;
179
182
// Restart it
180
- child = Command :: new ( & bin_name)
183
+ let mut child_l = Command :: new ( & bin_name) ;
184
+ let child_l = child_l
181
185
. args ( & args)
182
186
. env ( "PERSEUS_WATCHING_PROHIBITED" , "true" )
183
- . env ( "PERSEUS_USE_RELOAD_SERVER" , "true" ) // This is for internal use ONLY
187
+ . env ( "PERSEUS_USE_RELOAD_SERVER" , "true" ) ; // This is for internal use ONLY
188
+ #[ cfg( debug_assertions) ]
189
+ let child_l = child_l. env_remove ( "TEST_EXAMPLE" ) ; // We want to use the current directory in development
190
+ child = child_l
184
191
. group_spawn ( )
185
192
. map_err ( |err| WatchError :: SpawnSelfFailed { source : err } ) ?;
186
193
}
0 commit comments