mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-28 10:39:45 +00:00
Enforce a current directory being set for spawned commands
This commit is contained in:
parent
0f95e60da3
commit
5ce14b0439
22 changed files with 99 additions and 75 deletions
|
|
@ -1,6 +1,12 @@
|
|||
//! Discovery of `cargo` & `rustc` executables.
|
||||
|
||||
use std::{env, iter, path::PathBuf};
|
||||
use std::{
|
||||
env,
|
||||
ffi::OsStr,
|
||||
iter,
|
||||
path::{Path, PathBuf},
|
||||
process::Command,
|
||||
};
|
||||
|
||||
use camino::{Utf8Path, Utf8PathBuf};
|
||||
|
||||
|
|
@ -65,6 +71,14 @@ impl Tool {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn command(cmd: impl AsRef<OsStr>, working_directory: impl AsRef<Path>) -> Command {
|
||||
// we are `toolchain::command``
|
||||
#[allow(clippy::disallowed_methods)]
|
||||
let mut cmd = Command::new(cmd);
|
||||
cmd.current_dir(working_directory);
|
||||
cmd
|
||||
}
|
||||
|
||||
fn invoke(list: &[fn(&str) -> Option<Utf8PathBuf>], executable: &str) -> Utf8PathBuf {
|
||||
list.iter().find_map(|it| it(executable)).unwrap_or_else(|| executable.into())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue