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