diff --git a/completions/zsh b/completions/zsh index 2eb13da..048138b 100644 --- a/completions/zsh +++ b/completions/zsh @@ -14,6 +14,7 @@ args=( '(-k --kill)'{-k,--kill}'[Send SIGKILL to child processes (deprecated, use -s SIGKILL instead)]' '(-n --no-shell)'{-n,--no-shell}'[Do not wrap command in ''sh -c'' resp. ''cmd.exe /C'']' '--no-environment[Do not set WATCHEXEC_*_PATH environment variables for child process]' + '--no-meta[Ignore metadata changes]' '(-p --postpone)'{-p,--postpone}'[Wait until first change to execute command]' '(-r --restart)'{-r,--restart}'[Restart the process if it''s still running]' '(-V --version)'{-V,--version}'[Prints version information]' diff --git a/doc/watchexec.1.html b/doc/watchexec.1.html index 1f9f242..0cf7b28 100644 --- a/doc/watchexec.1.html +++ b/doc/watchexec.1.html @@ -90,6 +90,7 @@
-f, --filter pattern

Ignores modifications from paths that do not match pattern. This option can be specified multiple times, where a match on any given pattern causes the path to trigger command.

-s, --signal

Sends the specified signal (e.g. SIGKILL) to the child process. Defaults to SIGTERM.

-n, --no-shell

Execute command directly, do not wrap it in sh -c resp. cmd.exe /C. This is especially useful in combination with --signal, as the signal is then send directly to the specified command. While --no-shell is a little more performant than the default, it prevents using shell-features like pipes and redirects.

+
--no-meta

Ignore metadata changes

--no-environment

Do not set WATCHEXEC_*_PATH environment variables for child process.

-i, --ignore pattern

Ignores modifications from paths that match pattern. This option can be specified multiple times, and a match on any pattern causes the path to be ignored.

-w, --watch path

Monitor a specific path for changes. By default, the current working directory is watched. This may be specified multiple times, where a change in any watched directory (and subdirectories) causes command to be executed.

diff --git a/doc/watchexec.1.ronn b/doc/watchexec.1.ronn index c7f4d11..b885001 100644 --- a/doc/watchexec.1.ronn +++ b/doc/watchexec.1.ronn @@ -28,6 +28,9 @@ Sends the specified signal (e.g. `SIGKILL`) to the child process. Defaults to `S * `-n`, `--no-shell`: Execute command directly, do not wrap it in `sh -c` resp. `cmd.exe /C`. This is especially useful in combination with `--signal`, as the signal is then send directly to the specified command. While `--no-shell` is a little more performant than the default, it prevents using shell-features like pipes and redirects. +* `--no-meta`: +Ignore metadata changes. + * `--no-environment`: Do not set WATCHEXEC_*_PATH environment variables for child process. diff --git a/src/cli.rs b/src/cli.rs index dcef984..51fe376 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -58,6 +58,9 @@ pub struct Args { /// Do not wrap the commands in a shell. #[builder(default)] pub no_shell: bool, + /// Ignore metadata changes. + #[builder(default)] + pub no_meta: bool, /// Do not set WATCHEXEC_*_PATH environment variables for child process. #[builder(default)] pub no_environment: bool, @@ -210,6 +213,9 @@ where .help("Do not wrap command in 'sh -c' resp. 'cmd.exe /C'") .short("n") .long("no-shell")) + .arg(Arg::with_name("no-meta") + .help("Ignore metadata changes") + .long("no-meta")) .arg(Arg::with_name("no-environment") .help("Do not set WATCHEXEC_*_PATH environment variables for child process") .long("no-environment")) @@ -308,6 +314,7 @@ where debug: args.is_present("verbose"), run_initially: !args.is_present("postpone"), no_shell: args.is_present("no-shell"), + no_meta: args.is_present("no-meta"), no_environment: args.is_present("no-environment"), no_vcs_ignore: args.is_present("no-vcs-ignore"), no_ignore: args.is_present("no-ignore"), diff --git a/src/run.rs b/src/run.rs index 76e7ce0..b6dea0c 100644 --- a/src/run.rs +++ b/src/run.rs @@ -134,7 +134,7 @@ where loop { debug!("Waiting for filesystem activity"); - let paths = wait_fs(&rx, &filter, args.debounce); + let paths = wait_fs(&rx, &filter, args.debounce, args.no_meta); debug!("Paths updated: {:?}", paths); if !handler.on_update(&paths)? { @@ -282,7 +282,7 @@ pub fn run(args: Args) -> Result<()> { watch(&ExecHandler::new(args)?) } -fn wait_fs(rx: &Receiver, filter: &NotificationFilter, debounce: u64) -> Vec { +fn wait_fs(rx: &Receiver, filter: &NotificationFilter, debounce: u64, no_meta: bool) -> Vec { let mut paths = Vec::new(); let mut cache = HashMap::new(); @@ -291,6 +291,12 @@ fn wait_fs(rx: &Receiver, filter: &NotificationFilter, debounce: u64) -> if let Some(ref path) = e.path { let pathop = PathOp::new(path, e.op.ok(), e.cookie); + if let Some(op) = pathop.op { + if no_meta && PathOp::is_meta(op) { + continue; + } + } + // Ignore cache for the initial file. Otherwise, in // debug mode it's hard to track what's going on let excluded = filter.is_excluded(path);