@@ -10,6 +10,18 @@ use std::{
1010use tauri:: { AppHandle , Emitter } ;
1111use walkdir:: WalkDir ;
1212
13+ #[ cfg( target_os = "windows" ) ]
14+ const CREATE_NO_WINDOW : u32 = 0x08000000 ;
15+
16+ #[ cfg( target_os = "windows" ) ]
17+ fn hide_console_window ( command : & mut Command ) {
18+ use std:: os:: windows:: process:: CommandExt ;
19+ command. creation_flags ( CREATE_NO_WINDOW ) ;
20+ }
21+
22+ #[ cfg( not( target_os = "windows" ) ) ]
23+ fn hide_console_window ( _command : & mut Command ) { }
24+
1325#[ derive( Debug , Serialize ) ]
1426#[ serde( rename_all = "camelCase" ) ]
1527struct DetectedScript {
@@ -119,13 +131,14 @@ fn marker_names(path: &Path) -> Vec<String> {
119131}
120132
121133fn command_output ( path : & Path , program : & str , args : & [ & str ] ) -> Option < String > {
122- let output = Command :: new ( program)
134+ let mut command = Command :: new ( program) ;
135+ command
123136 . args ( args)
124137 . current_dir ( path)
125138 . stdin ( Stdio :: null ( ) )
126- . stderr ( Stdio :: null ( ) )
127- . output ( )
128- . ok ( ) ?;
139+ . stderr ( Stdio :: null ( ) ) ;
140+ hide_console_window ( & mut command ) ;
141+ let output = command . output ( ) . ok ( ) ?;
129142
130143 output
131144 . status
@@ -749,13 +762,15 @@ fn create_project_from_template(
749762 }
750763
751764 if init_git && which:: which ( "git" ) . is_ok ( ) {
752- let _ = Command :: new ( "git" )
765+ let mut command = Command :: new ( "git" ) ;
766+ command
753767 . args ( [ "init" ] )
754768 . current_dir ( & destination)
755769 . stdin ( Stdio :: null ( ) )
756770 . stdout ( Stdio :: null ( ) )
757- . stderr ( Stdio :: null ( ) )
758- . status ( ) ;
771+ . stderr ( Stdio :: null ( ) ) ;
772+ hide_console_window ( & mut command) ;
773+ let _ = command. status ( ) ;
759774 }
760775
761776 Ok ( CreatedProject {
@@ -1015,7 +1030,7 @@ fn shell_command(script: &str) -> Command {
10151030 use std:: os:: windows:: process:: CommandExt ;
10161031 let mut command = Command :: new ( "cmd.exe" ) ;
10171032 command. args ( [ "/D" , "/S" , "/C" , script] ) ;
1018- command. creation_flags ( 0x08000000 ) ;
1033+ command. creation_flags ( CREATE_NO_WINDOW ) ;
10191034 command
10201035 }
10211036
@@ -1235,11 +1250,14 @@ fn start_process(
12351250fn stop_process ( pid : u32 ) -> Result < ( ) , String > {
12361251 #[ cfg( target_os = "windows" ) ]
12371252 {
1238- let status = Command :: new ( "taskkill" )
1253+ let mut command = Command :: new ( "taskkill" ) ;
1254+ command
12391255 . args ( [ "/PID" , & pid. to_string ( ) , "/T" , "/F" ] )
12401256 . stdin ( Stdio :: null ( ) )
12411257 . stdout ( Stdio :: null ( ) )
1242- . stderr ( Stdio :: null ( ) )
1258+ . stderr ( Stdio :: null ( ) ) ;
1259+ hide_console_window ( & mut command) ;
1260+ let status = command
12431261 . status ( )
12441262 . map_err ( |error| format ! ( "Prozess konnte nicht beendet werden: {error}" ) ) ?;
12451263 if status. success ( ) {
0 commit comments