mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-27 21:51:33 +02:00
Actually watch files in example
This commit is contained in:
parent
b2effda341
commit
b42336cb74
@ -20,6 +20,7 @@ async fn main() -> color_eyre::eyre::Result<()> {
|
||||
});
|
||||
|
||||
let mut runtime = RuntimeConfig::default();
|
||||
runtime.pathset(["src"]);
|
||||
runtime.command(["date"]);
|
||||
runtime.on_action(|action: Action| async move {
|
||||
eprintln!("Watchexec Action: {:?}", action);
|
||||
@ -32,7 +33,10 @@ async fn main() -> color_eyre::eyre::Result<()> {
|
||||
{
|
||||
action.outcome(Outcome::Exit);
|
||||
} else {
|
||||
action.outcome(Outcome::both(Outcome::Stop, Outcome::Start));
|
||||
action.outcome(Outcome::if_running(
|
||||
Outcome::both(Outcome::Stop, Outcome::Start),
|
||||
Outcome::Start,
|
||||
));
|
||||
}
|
||||
|
||||
Ok::<(), Infallible>(())
|
||||
|
@ -71,6 +71,7 @@ impl Shell {
|
||||
/// - Panics if the string in the `Unix` variant is empty or only whitespace.
|
||||
pub fn to_command(&self, cmd: &[String]) -> Command {
|
||||
assert!(!cmd.is_empty(), "cmd was empty");
|
||||
trace!(shell=?self, ?cmd, "constructing command");
|
||||
|
||||
match self {
|
||||
Shell::None => {
|
||||
|
@ -48,8 +48,13 @@ impl Watchexec {
|
||||
) -> Result<Arc<Self>, CriticalError> {
|
||||
debug!(?init, ?runtime, pid=%std::process::id(), "initialising");
|
||||
|
||||
let (fs_s, fs_r) = watch::channel(take(&mut runtime.fs));
|
||||
let (ac_s, ac_r) = watch::channel(take(&mut runtime.action));
|
||||
let (fs_s, fs_r) = watch::channel(fs::WorkingData::default());
|
||||
|
||||
// TODO: figure out how to do this (aka start the fs work) after the main task start lock
|
||||
trace!("sending initial config to fs worker");
|
||||
fs_s.send(take(&mut runtime.fs))
|
||||
.expect("cannot send to just-created fs watch (bug)");
|
||||
|
||||
trace!("creating main task");
|
||||
let notify = Arc::new(Notify::new());
|
||||
|
Loading…
Reference in New Issue
Block a user