light_program_test/utils/
find_light_bin.rs1use std::path::PathBuf;
2
3pub fn find_light_bin() -> Option<PathBuf> {
4 #[cfg(not(feature = "devenv"))]
6 {
7 use std::process::Command;
8 let output = Command::new("which")
9 .arg("light")
10 .output()
11 .expect("Failed to execute 'which light'");
12
13 if !output.status.success() {
14 return None;
15 }
16 let light_path = String::from_utf8_lossy(&output.stdout).trim().to_string();
18 let mut light_bin_path = PathBuf::from(light_path);
20 light_bin_path.pop(); let node_modules_bin =
24 light_bin_path.join("../lib/node_modules/@lightprotocol/zk-compression-cli/bin");
25
26 Some(node_modules_bin.canonicalize().unwrap_or(node_modules_bin))
27 }
28 #[cfg(feature = "devenv")]
29 {
30 println!("Use only in light protocol monorepo. Using 'git rev-parse --show-toplevel' to find the location of 'light' binary");
31 let light_protocol_toplevel = String::from_utf8_lossy(
32 &std::process::Command::new("git")
33 .arg("rev-parse")
34 .arg("--show-toplevel")
35 .output()
36 .expect("Failed to get top-level directory")
37 .stdout,
38 )
39 .trim()
40 .to_string();
41 let light_path = PathBuf::from(format!("{}/target/deploy/", light_protocol_toplevel));
42 Some(light_path)
43 }
44}