1use std::process::Command;
4
5pub mod adoption;
6mod artifact_io;
7mod bootstrap_store;
8mod build_profile;
9pub mod build_provenance;
10pub mod candid_endpoints;
11pub mod canic_metadata;
12pub mod canister_build;
13pub mod canister_ready;
14mod cargo_metadata;
15pub mod cycle_balance;
16pub mod deployment_catalog;
17pub mod deployment_truth;
18pub mod duration;
19pub mod evidence_envelope;
20pub mod format;
21pub mod icp;
22pub mod icp_config;
23pub mod install_root;
24pub mod installed_deployment;
25pub mod policy_gate;
26pub mod registry;
27pub mod release_set;
28pub mod replica_query;
29pub mod response_parse;
30pub mod state_manifest;
31pub mod subnet_registry;
32pub mod table;
33#[cfg(test)]
34mod test_support;
35mod workspace_discovery;
36
37pub(crate) fn cargo_command() -> Command {
38 let cargo = std::env::var_os("CARGO").unwrap_or_else(|| "cargo".into());
39 let mut command = Command::new(cargo);
40
41 if let Some(toolchain) = std::env::var_os("RUSTUP_TOOLCHAIN") {
42 command.env("RUSTUP_TOOLCHAIN", toolchain);
43 }
44
45 command
46}
47
48pub(crate) fn icp_environment_from_env() -> String {
49 std::env::var("ICP_ENVIRONMENT").unwrap_or_else(|_| "local".to_string())
50}
51
52pub(crate) fn should_export_candid_artifacts(environment: &str) -> bool {
53 environment == "local"
54}
55
56pub(crate) fn remove_optional_file(path: &std::path::Path) -> std::io::Result<()> {
57 match std::fs::remove_file(path) {
58 Ok(()) => Ok(()),
59 Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(()),
60 Err(err) => Err(err),
61 }
62}
63
64#[cfg(test)]
65mod tests;