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