소스 검색

Fix program not found by fallback to ANSI-escape

Shiroko 2 년 전
부모
커밋
dddaec20fc
1개의 변경된 파일11개의 추가작업 그리고 13개의 파일을 삭제
  1. 11 13
      src/server/mod.rs

+ 11 - 13
src/server/mod.rs

@@ -419,19 +419,17 @@ pub struct PrettierOptions {
 }
 
 fn print_console_info(port: u16, config: &CrateConfig, options: PrettierOptions) {
-    print!(
-        "{}",
-        String::from_utf8_lossy(
-            &Command::new(if cfg!(target_os = "windows") {
-                "cls"
-            } else {
-                "clear"
-            })
-            .output()
-            .unwrap()
-            .stdout
-        )
-    );
+    if let Ok(native_clearseq) = Command::new(if cfg!(target_os = "windows") {
+        "cls"
+    } else {
+        "clear"
+    })
+    .output() {
+        print!("{}", String::from_utf8_lossy(&native_clearseq.stdout));
+    } else {
+        // Try ANSI-Escape characters
+        print!("\x1b[2J\x1b[H");
+    }
 
     // for path in &changed {
     //     let path = path