File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " create-tauri-app " : " patch"
3+ " create-tauri-app-js " : " patch"
4+ ---
5+
6+ Recursively clean the target directory if bootstrapping a template into a non-empty directory.
7+
Original file line number Diff line number Diff line change @@ -269,9 +269,19 @@ where
269269 // Remove the target dir contents before rendering the template
270270 // SAFETY: Upon reaching this line, the user already accepted to overwrite
271271 if target_dir. exists ( ) {
272- for file in fs:: read_dir ( & target_dir) ?. flatten ( ) {
273- let _ = fs:: remove_file ( file. path ( ) ) ;
272+ fn clean_dir ( dir : & std:: path:: PathBuf ) -> anyhow:: Result < ( ) > {
273+ for entry in fs:: read_dir ( dir) ?. flatten ( ) {
274+ let path = entry. path ( ) ;
275+ if entry. file_type ( ) ?. is_dir ( ) {
276+ clean_dir ( & path) ?;
277+ std:: fs:: remove_dir ( path) ?;
278+ } else {
279+ fs:: remove_file ( path) ?;
280+ }
281+ }
282+ Ok ( ( ) )
274283 }
284+ clean_dir ( & target_dir) ?;
275285 } else {
276286 let _ = fs:: create_dir_all ( & target_dir) ;
277287 }
You can’t perform that action at this time.
0 commit comments