mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-29 14:41:35 +02:00
use cfg attributes instead of macro for OS specific functionality
This commit is contained in:
parent
5cd6ee5a9b
commit
59724589ea
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1,6 +1,6 @@
|
|||||||
[root]
|
[root]
|
||||||
name = "watchexec"
|
name = "watchexec"
|
||||||
version = "0.11.0"
|
version = "1.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap 2.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"clap 2.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -15,40 +15,33 @@ impl Runner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_family = "windows")]
|
||||||
fn clear(&self) {
|
fn clear(&self) {
|
||||||
// TODO: determine better way to do this
|
let _ = Command::new("cls").status();
|
||||||
let clear_cmd;
|
|
||||||
if cfg!(target_os = "windows") {
|
|
||||||
clear_cmd = "cls";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
clear_cmd = "clear";
|
|
||||||
}
|
|
||||||
|
|
||||||
let _ = Command::new(clear_cmd).status();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_family = "unix")]
|
||||||
|
fn clear(&self) {
|
||||||
|
let _ = Command::new("clear").status();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_family = "windows")]
|
||||||
fn invoke(&self, cmd: &str) -> Option<Child> {
|
fn invoke(&self, cmd: &str) -> Option<Child> {
|
||||||
let shell;
|
Command::new("cmd.exe")
|
||||||
let shell_cmd_arg;
|
.arg("/C")
|
||||||
|
|
||||||
if cfg!(target_os = "windows") {
|
|
||||||
shell = "cmd.exe";
|
|
||||||
shell_cmd_arg = "/C";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
shell = "sh";
|
|
||||||
shell_cmd_arg = "-c";
|
|
||||||
}
|
|
||||||
|
|
||||||
Command::new(shell)
|
|
||||||
.arg(shell_cmd_arg)
|
|
||||||
.arg(cmd)
|
.arg(cmd)
|
||||||
.spawn()
|
.spawn()
|
||||||
.ok()
|
.ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_family = "unix")]
|
||||||
|
fn invoke(&self, cmd: &str) -> Option<Child> {
|
||||||
|
Command::new("sh")
|
||||||
|
.arg("-c")
|
||||||
|
.arg(cmd)
|
||||||
|
.spawn()
|
||||||
|
.ok()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn run_command(&mut self, cmd: &str) {
|
pub fn run_command(&mut self, cmd: &str) {
|
||||||
if let Some(ref mut child) = self.process {
|
if let Some(ref mut child) = self.process {
|
||||||
|
Loading…
Reference in New Issue
Block a user