DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/IPC/WindServiceHandlers/Git/
HandleIsAvailable.rs1use std::sync::OnceLock;
6
7use serde_json::{Value, json};
8use tokio::process::Command;
9
10use crate::dev_log;
11
12pub async fn Fn(_Arguments:Vec<Value>) -> Result<Value, String> {
13 static CACHE:OnceLock<bool> = OnceLock::new();
18
19 if CACHE.get() == Some(&true) {
20 return Ok(json!(true));
21 }
22
23 let Available = Command::new("git")
24 .arg("--version")
25 .output()
26 .await
27 .map(|O| O.status.success())
28 .unwrap_or(false);
29
30 if Available {
31 let _ = CACHE.set(true);
32 }
33
34 dev_log!("git", "[Git] isAvailable={}", Available);
35
36 Ok(json!(Available))
37}