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