added better path handling

This commit is contained in:
Kasper Juul Hermansen 2022-08-13 17:48:07 +02:00
parent f0488cded8
commit dc0f27a8e8
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912

View File

@ -1,4 +1,4 @@
use std::process::Command;
use std::{path::PathBuf, process::Command};
use crate::cli::CuddleVariable;
@ -26,7 +26,13 @@ Starting running shell action: {}
self.path.clone()
);
let mut process = Command::new(self.path)
let path = PathBuf::from(self.path.clone());
if !path.exists() {
log::info!("script='{}' not found, aborting", path.to_string_lossy());
return Err(anyhow::anyhow!("file not found aborting"));
}
let mut process = Command::new(path)
.current_dir(".")
.envs(variables.iter().map(|v| {
log::trace!("{:?}", v);