Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/toolchain/src/lib.rs')
-rw-r--r--crates/toolchain/src/lib.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/crates/toolchain/src/lib.rs b/crates/toolchain/src/lib.rs
index e3b30ff9cd..8b7bf1a806 100644
--- a/crates/toolchain/src/lib.rs
+++ b/crates/toolchain/src/lib.rs
@@ -71,11 +71,22 @@ impl Tool {
}
}
-pub fn command(cmd: impl AsRef<OsStr>, working_directory: impl AsRef<Path>) -> Command {
+#[allow(clippy::disallowed_types)] /* generic parameter allows for FxHashMap */
+pub fn command<H>(
+ cmd: impl AsRef<OsStr>,
+ working_directory: impl AsRef<Path>,
+ extra_env: &std::collections::HashMap<String, Option<String>, H>,
+) -> Command {
// we are `toolchain::command``
#[allow(clippy::disallowed_methods)]
let mut cmd = Command::new(cmd);
cmd.current_dir(working_directory);
+ for env in extra_env {
+ match env {
+ (key, Some(val)) => cmd.env(key, val),
+ (key, None) => cmd.env_remove(key),
+ };
+ }
cmd
}