diff --git a/src/config.rs b/src/config.rs index 5de60f1..81712f9 100644 --- a/src/config.rs +++ b/src/config.rs @@ -15,6 +15,8 @@ use std::path::PathBuf; +use crate::process::Shell; + /// Arguments to the watcher #[derive(Builder, Clone, Debug)] #[builder(setter(into, strip_option))] @@ -46,6 +48,9 @@ pub struct Config { /// Run the commands right after starting. #[builder(default = "true")] pub run_initially: bool, + /// Specify the shell to use. + #[builder(default)] + pub shell: Shell, /// Do not wrap the commands in a shell. #[builder(default)] pub no_shell: bool, diff --git a/src/lib.rs b/src/lib.rs index e7ed46b..bbc4031 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,6 +34,7 @@ pub mod run; mod signal; mod watcher; +pub use process::Shell; pub use run::{run, watch, Handler}; #[deprecated(since = "1.15.0", note = "Config has moved to config::Config")] diff --git a/src/process.rs b/src/process.rs index f7f95c7..6031eb8 100644 --- a/src/process.rs +++ b/src/process.rs @@ -19,6 +19,18 @@ pub enum Shell { Powershell, } +impl Default for Shell { + #[cfg(windows)] + fn default() -> Self { + Self::Powershell + } + + #[cfg(not(windows))] + fn default() -> Self { + Self::Unix("sh".into()) + } +} + pub fn spawn( cmd: &[String], updated_paths: &[PathOp],