return a PathBuf instead of String

This commit is contained in:
Craig Disselkoen 2020-05-06 12:39:11 -07:00
parent 1b76b4281e
commit 44b01ccff3
2 changed files with 9 additions and 8 deletions

View file

@ -89,9 +89,10 @@ fn create_command_text(program: &str, args: &[&str]) -> String {
format!("{} {}", program, args.join(" "))
}
fn run_command_in_cargo_dir(cargo_toml: &Path, program: &str, args: &[&str]) -> Result<Output> {
fn run_command_in_cargo_dir(cargo_toml: impl AsRef<Path>, program: impl AsRef<Path>, args: &[&str]) -> Result<Output> {
let program = program.as_ref().as_os_str().to_str().expect("Invalid Unicode in path");
let output = Command::new(program)
.current_dir(cargo_toml.parent().unwrap())
.current_dir(cargo_toml.as_ref().parent().unwrap())
.args(args)
.output()
.context(format!("{} failed", create_command_text(program, args)))?;