Build the `PATH` value with optional language introspection wrappers prepended. When `enable_introspection` is true, the Node.js and Go wrapper script directories are prepended to the current `PATH`. Otherwise the current `PATH` is returned unchanged.
(enable_introspection: bool)
| 47 | /// directories are prepended to the current `PATH`. Otherwise the current |
| 48 | /// `PATH` is returned unchanged. |
| 49 | pub fn build_path_env(enable_introspection: bool) -> Result<String> { |
| 50 | let path_env = std::env::var("PATH").unwrap_or_default(); |
| 51 | if !enable_introspection { |
| 52 | return Ok(path_env); |
| 53 | } |
| 54 | |
| 55 | let node_path = introspected_nodejs::setup() |
| 56 | .map_err(|e| anyhow!("failed to setup NodeJS introspection. {e}"))?; |
| 57 | let go_path = introspected_golang::setup() |
| 58 | .map_err(|e| anyhow!("failed to setup Go introspection. {e}"))?; |
| 59 | |
| 60 | Ok(format!( |
| 61 | "{}:{}:{}", |
| 62 | node_path.to_string_lossy(), |
| 63 | go_path.to_string_lossy(), |
| 64 | path_env, |
| 65 | )) |
| 66 | } |
| 67 | |
| 68 | pub fn is_codspeed_debug_enabled() -> bool { |
| 69 | std::env::var("CODSPEED_LOG") |
no test coverage detected