Commit Graph

280 Commits

Author SHA1 Message Date
Félix Saparelli 4ceb70f6bf [docs] Fix logic inversion in on_manual doc comment 2019-01-27 10:24:24 +13:00
Félix Saparelli 578ffa1deb [run] Fix outdated comment in ExecHandler 2019-01-26 17:42:36 +13:00
Félix Saparelli 5846b64020 [run] Further dry the ExecHandler 2019-01-26 17:32:48 +13:00
Félix Saparelli 3dd2f797ab [process] Remove some more unwrap 2019-01-26 17:26:33 +13:00
Félix Saparelli 6a23f77687 [run] Pass ops by reference when possible 2019-01-26 17:20:29 +13:00
Félix Saparelli ede5505a6b [run] Dry spawning the child process 2019-01-26 17:16:07 +13:00
Félix Saparelli 5e44cafb94 [windows] Attempt to use tput to clear the screen
In some situations, this may clear the screen better than a call to
`cls`, and in all other cases `cls` is called anyway.

May help #99
2019-01-26 15:22:09 +13:00
Félix Saparelli 6f473bcd87 [meta] Run formatter 2019-01-26 15:15:27 +13:00
Félix Saparelli aae5a216b0 [api] Make watchexec take a Handler rather than a callback
Instead of special-casing the callback, which is the path least-taken,
switch the internals to a Handler model, where the default behaviour is
an implementation of a Handler, and external callers can implement their
own Handlers and pass them in.

While doing so, change all unwraps in run::run to returning Errs, and
expand the watchexec Error enum to accommodate. That should make it
easier to use as a library.

Also, differentiate between "manual" and "on update" runs. For now the
only manual run is the initial run, but this paves the way for e.g.
keyboard- or signal- triggered runs.
2019-01-26 14:45:13 +13:00
Félix Saparelli ac3a4f0717 [pathop] Revert changes adding a time field 2019-01-26 14:40:30 +13:00
David Ziegler 7b3daeef9c Major changes for c bindings integration as third party crate (see project: github/InfinityMod/watchexec_c).
Changed version to 1.9.3 for third party crate compatibility detection.
2019-01-23 18:56:09 +01:00
Magnus Bergmark 9fd25dd667
Use setsid() instead of setpgid()
This makes it possible to run commands that allocates TTYs and still
capture their output and reap the process on completion.

> setpgid — set process group ID for job control
> setsid — create session and set process group ID

With this in place, the `waitpid` call detects that the process has
exited even if the process allocated a TTY, and is able to unblock the
runner and continue.

Further, the output of the command is also shown in the controlling
terminal.
2019-01-17 13:21:27 +01:00
Félix Saparelli f6b16813aa Cfg off remaining items for a clean win/mac build
Closes #98
2018-10-05 20:56:06 +13:00
Félix Saparelli ba23ed09f6 Fix tests 2018-09-09 16:16:40 +12:00
Félix Saparelli dc712197c0 1.9.2: revert whitespace changes 2018-09-09 16:03:01 +12:00
Félix Saparelli 3c1eaa51f7 Add missing impl for StdError 2018-09-09 10:38:07 +12:00
Félix Saparelli 2c5c145042 Extract errors into one thing and return a result more often 2018-09-08 23:51:44 +12:00
Félix Saparelli a6163cc599 Formatting 2018-09-08 20:08:36 +12:00
Félix Saparelli 9c60148b66
Merge pull request #95 from watchexec/wrap-whitespace-in-args
Wrap whitespace and quotes in command arguments
2018-09-08 19:44:39 +12:00
Félix Saparelli 718647e386
Merge branch 'master' into fix_panic 2018-09-08 19:43:20 +12:00
Félix Saparelli 7375db5ce9 Also wrap when there’s quotes but no whitespace 2018-08-22 08:17:36 +12:00
Félix Saparelli 21d4080183 Wrap whitespace in arguments
Fixes #82
Fixes #87
2018-08-22 07:15:20 +12:00
Félix Saparelli 39a4a52f80 Restore 1.20 compatibility 2018-08-22 07:14:55 +12:00
Félix Saparelli ef0e6df8d4 Remove duplication between main/lib files 2018-08-22 00:10:57 +12:00
Félix Saparelli f61b7507af Update dependencies 2018-08-19 20:58:47 +12:00
Félix Saparelli 31fdca564a
Merge pull request #93 from tailhook/max_user_watches
Add a warning and fallback on polling mode if limit exceeded
2018-08-19 20:29:44 +12:00
Félix Saparelli 93bd1d9881
Merge pull request #77 from bruceg/master
Fix some default ignore pattern issues
2018-08-19 20:23:49 +12:00
Paul Colomiets a2d0a251da Add a warning and fallback on polling mode if limit exceeded
Works only on linux (not sure how error is named on other systems):
```
*** System notification limit is too small, falling back to polling
mode.
*** For better performance increase system limit:
   sysctl fs.inotify.max_user_watches=524288
*** Polling for changes every 1000 ms
```

Fixes #62
2018-08-02 19:36:50 +03:00
Oliver Jan Krylow 8de93a8fd2
Bumps __nix__ to __0.11.0__ in order to support OpenBSD 6.3+. 2018-07-30 21:20:12 +02:00
Bruce Guenter 1d8d6595e0 Add .pyo to the Python temporary file ignore
Python, when invoked with the -O option, writes compiled code to .pyo
files instead of .pyc. Add this to the default ignores list.
2018-02-08 14:53:12 -06:00
Bruce Guenter 422546b175 Add Emacs temporary files to the default ignored list
Emacs generates temporary backup files while editing named "#FILENAME#"
and ".#FILENAME". Ignore these by default.
2018-02-08 14:53:11 -06:00
Bruce Guenter c98bea3118 Fix default ignore for vim temporary files
.swp files are created by vim to store editing state while a file is
open. However, it may also create .swo, .swn, etc files if .swp already
exists. Also, the temporary files are always hidden (start with ".").
Finally, vim temporarily creates .swpx files as well which are caught by
inotify.

This change fixes the *.swp pattern to only match hidden files and to
match the other vim temporary files.
2018-02-08 14:53:08 -06:00
James Kominick 31b5e56959 don't panic on missing folder
issue #71
- Add some basic error handling
- Convert missing folder panic to error
2017-12-13 23:10:12 -05:00
Jim McGrath 9b4e74ed30 fix screen clearing on windows 2017-12-06 11:40:04 -06:00
Josh Gao 76d959b27b Use `tput reset` to clear screen.
Use `tput reset` instead of `clear` so that scrollback is cleared in
addition to the currently visible portion of the terminal.
2017-11-21 00:55:58 -05:00
Matt Green 3de894e07c Merge pull request #70 from mattgathu/fix_clippy_warnings_run
fix (src/run.rs): fixed cargo clippy warnings
2017-10-09 08:54:41 -04:00
Matt Green b035cbf44a Merge pull request #69 from mattgathu/fix_clippy_warnings_process
fix (src/process.rs): fix cargo clippy linter warnings
2017-10-09 08:53:55 -04:00
Matt Green 8770ae3967 Handle relative ignores better? 2017-10-07 15:50:47 -04:00
Matt Gathu 8509cbfd77
fix (src/run.rs): fixed cargo clippy warnings
This addresses warnings reported by cargo clippy on `src/run.rs`:

* warning: this expression borrows a reference that is immediately dereferenced by the compiler

reference:
- https://rust-lang-nursery.github.io/rust-clippy/v0.0.165/index.html#needless_borrow
- https://github.com/rust-lang-nursery/rust-clippy
2017-10-06 14:31:36 +03:00
Matt Gathu 775eb47dde
fix (src/process.rs): fix cargo clippy linter warnings
This PR fixes lint warnings generated by cargo-clippy:

- **warning**: you should put `notify::ops::RENAME` between ticks in the documentation
- **warning**: use of `or_insert` followed by a function call

I have run `cargo test` and these changes do not break any of the tests :-)

reference:
--

* https://rust-lang-nursery.github.io/rust-clippy/v0.0.165/index.html#doc_markdown
* https://rust-lang-nursery.github.io/rust-clippy/v0.0.165/index.html#or_fun_call
* https://github.com/rust-lang-nursery/rust-clippy
2017-10-06 13:55:21 +03:00
James Kominick 8bd9bb3c25 detailed update information
issue #59
- Keep track of `notify::op::Op`s associated with each updated path
- Collect paths into `notify::op::Op` categories and pass them on as
  environment vars
- Set a COMMON_PATH and use relative paths if more than one unique
  path was touched
2017-09-09 13:55:44 -04:00
Matt Green 06fd2954dd Merge pull request #64 from jaemk/configurable_debounce
Add `-d, --debounce` option
2017-09-08 16:16:19 -04:00
James Kominick 0e34123023 Add `-d, --debounce` option
- Add configurable debounce timeout option behind `-d, --debounce`
- Move `-d, --debug` flags to `-v, --verbose`
2017-09-07 19:44:57 -04:00
Lilian A. Moraru e39256cfb2 Update dependencies and other small improvements 2017-08-26 22:07:06 +03:00
Matt Green 3fc501c4f0 Windows: fix waiting for job to finish; closes #55 2017-05-18 13:22:46 -04:00
Matt Green 6ebb7bc7b3 Also ignore changes to ignored dirs themselves 2017-05-10 12:02:49 -04:00
Matt Green e6de016cb9 Ensure correct path separators are used for VCS ignore dirs 2017-04-27 15:39:12 -04:00
Matt Green f9a3cade26 Add common VCS dirs to default ignore list (fixes #54) 2017-04-27 15:20:44 -04:00
Les Aker 356dac189d add no-default-ignore option, fixes #45 2017-04-25 21:17:45 -04:00
Matt Green fe0d5243bd Remove /.* ignore pattern (see #45) 2017-04-25 16:48:44 -04:00
Félix Saparelli f5bf4ef98b
Add library interface 2017-04-25 11:31:50 +12:00
Chris Aumann f88f1b36c3 Refactor command assembly
Kudos to https://www.reddit.com/user/burntsushi from the /r/rust community!
See: https://www.reddit.com/r/rust/comments/64ic0q/idiomatic_string_processing/
2017-04-10 14:13:27 +02:00
Chris Aumann a395ed84cd Remove useless format!()
This was a hint by `cargo clippy`
2017-04-10 00:20:57 +02:00
Chris Aumann df72aaf977 Use if-else statements instead of boolean match
This was a hint by `cargo clippy`
2017-04-10 00:20:57 +02:00
Chris Aumann 780b54b34e Port --no-shell to Windows 2017-04-10 00:20:57 +02:00
Chris Aumann 5a7ccf759b Adapt spawn() test for Unix 2017-04-10 00:20:27 +02:00
Chris Aumann ee5e93e6af Add support for --no-shell option 2017-04-10 00:19:58 +02:00
Chris Aumann 5b486e2ae6 Remove deprecated comment (before_exec) 2017-04-06 22:54:02 +02:00
Chris Aumann 264ec282d6 Use a tuple to match scenarios 2017-04-02 21:28:00 +02:00
Chris Aumann 4763de3790 Re-add --kill flag for compatibility
--kill translates to --signal SIGKILL
2017-04-02 21:21:30 +02:00
Chris Aumann 627f828b3c Rename wait_process() to signal_process() 2017-04-02 21:21:30 +02:00
Chris Aumann d5da94fcaf Add check for conflicting --signal and --postpone arguments 2017-04-02 21:21:30 +02:00
Chris Aumann c98d0e6cfd Decouple --restart and --signal, so they both make sense
This change takes account of the following four use cases:

1. Make sure the previous run was ended, then run the command again (default)
2. Just send a specified signal to the child, do nothing more (--signal given)
3. Send SIGTERM to the child, wait for it to exit, then run the command again (--restart given)
4. Send a specified signal to the child, wait for it to exit, then run the command again (--restart and --signal given)
2017-04-02 21:21:30 +02:00
Chris Aumann 56ddfcbaee Apply rustfmt-0.8.1 2017-04-02 21:21:30 +02:00
Chris Aumann 3a5ff290d5 Use a more idiomatic way to set --signal 2017-04-02 21:19:53 +02:00
Chris Aumann a2f6b0013f Add windows compatibility 2017-04-02 21:19:53 +02:00
Chris Aumann 0a445c9f76 Move convert_to_libc() method to signal.rs 2017-04-02 21:19:53 +02:00
Chris Aumann 4adde457dd Actually use signal specified in --signal option 2017-04-02 21:19:53 +02:00
Chris Aumann 382981e22d Add more signals to SigSet mask 2017-04-02 21:19:53 +02:00
Chris Aumann eebe966b50 Remove deprecated signal functions 2017-04-02 21:19:53 +02:00
Chris Aumann 24e9b0c1c5 Migrate to nix::sys::signal::Signal 2017-04-02 21:19:52 +02:00
Chris Aumann 68caf04269 First commit to add a generic --signal flag 2017-04-02 21:19:52 +02:00
Chris Aumann f62c3724b2 Use before_exec as process_exec landed in stable 2017-03-24 17:11:24 +01:00
Matt Green 125e7eb7c8 rustfmt & clippy fixes 2017-02-04 16:26:59 -05:00
Matt Green e16a6b3a24 Support watching multiple paths 2017-02-04 16:18:02 -05:00
Matt Green 53c1f39919 Load + handle multiple .gitignore files in project dir 2017-02-04 14:53:27 -05:00
Matt Green b2b0a60ca5 Add -1 option for integration testing, closes #35 2017-01-27 15:27:44 -05:00
Matt Green 0d5de7c4da rustfmt 2017-01-27 13:13:37 -05:00
Matt Green ebcb5976ba Use globset for ignore matching; closes #14 and #23 2017-01-27 13:00:13 -05:00
Matt Green fd2d6e364a Add -k to support sending SIGKILL 2017-01-16 14:18:38 -05:00
Matt Green 6b7351d45b Remove kill/wait tests as process handling is async now 2016-12-20 13:42:39 -05:00
Matt Green dddc1e8886 Fix Windows warnings 2016-12-20 13:25:08 -05:00
Matt Green 09448cd91e Fix reap() hanging when child processes are still running 2016-12-20 13:21:24 -05:00
Matt Green 171132a722 rustfmt & clippy fixes 2016-12-20 12:20:21 -05:00
Matt Green b2c809c87a SIGCHLD handling 2016-12-20 11:44:18 -05:00
Matt Green a925cb356a Fix sending SIGKILL by default when restarting processes 2016-12-19 15:36:59 -05:00
Matt Green 9c65e816da Add -k option to send SIGKILL instead of SIGTERM; closes #31 2016-12-19 11:37:20 -05:00
Matt Green 787c31040c Remask received signal after re-raising it 2016-12-15 09:41:10 -05:00
Matt Green 154c23a5a4 Propagate SIGTSTP/SIGCONT to children 2016-12-14 20:19:58 -05:00
Matt Green 54baf4e384 Add process::spawn function 2016-11-23 12:59:56 -05:00
Matt Green f768721ca3 Remove --watch option, always watch cwd 2016-11-17 08:45:55 -05:00
Matt Green 0e9dafffc8 Unix: pipe read/write handles EINTR 2016-11-16 20:18:46 -05:00
Matt Green 12557d11bf Fix setpgid() racing killpg()/waitpid() in tests 2016-11-16 08:55:15 -05:00
Matt Green e4557e462b Wait for child process, not any child process in group 2016-11-15 22:43:51 -05:00
Matt Green 5b2858e6d6 Die quietly if exec() fails 2016-11-15 17:04:15 -05:00
Matt Green 3bf3086a29 Replace before_exec with fork/exec, removing Rust nightly requirement 2016-11-15 16:55:29 -05:00
Matt Green bdce629782 Drop size optimizations that require nightly builds 2016-11-13 18:34:23 -05:00
Matt Green 0ef334e2a1 Size optimizations 2016-11-10 19:43:13 -05:00
Matt Green 68960fec9a Style fixes 2016-11-09 17:48:38 -05:00
Matt Green 48b0def80d Fix warnings in tests 2016-11-09 17:37:35 -05:00
Matt Green 2d2a8cb079 rustfmt 2016-11-09 17:25:52 -05:00
Matt Green 707fa2e952 Windows compilation fixes 2016-11-09 17:20:13 -05:00
Matt Green 6523f6edf5 Cleanup, initial Windows implementation of interrupt handler 2016-11-09 17:00:24 -05:00
Matt Green cf0a98b7a5 Remove use of select! 2016-11-09 09:44:00 -05:00
Matt Green 0d85d8275a Fix gitignore searching not terminating in some cases; closes #25 2016-11-08 17:52:29 -05:00
David Raifaizen dfe9dcc338 Refactoring get_longest_common_path to be simpler and more efficient 2016-11-05 08:42:45 -04:00
Matt Green a2e66f179c Upgrade to notify 3; closes #22 2016-11-03 17:20:43 -04:00
Matt Green 06bcef5853 Use globset in NotificationFilter; closes #24 2016-11-03 17:04:39 -04:00
Matt Green 8f916c495f Apply clippy suggested fixes 2016-10-30 12:37:34 -04:00
Matt Green 69eedd4cc5 rustfmt fixes 2016-10-30 12:28:54 -04:00
Matt Green d859b4b70e Drop threadpool dep (was spawning threads over and over) 2016-10-30 12:28:11 -04:00
Matt Green 2d7715f8d7 Merge pull request #20 from craftytrickster/common-prefix
Creating method to update the watch_exec variable with the greatest c…
2016-10-30 10:06:40 -04:00
David Raifaizen 8713140a4e Creating method to update the watch_exec variable with the greatest common path found among the changed filepaths 2016-10-29 14:39:48 -04:00
Matt Green 85f0a4aaaf Make --run-initially default, add --postpone flag to disable 2016-10-29 10:43:45 -04:00
Matt Green 82713fc906 Fix watching multiple dirs with differing roots 2016-10-29 10:24:31 -04:00
Matt Green 9652aeb837 Fix dotted dir default filter to only fire on dirs 2016-10-29 10:21:04 -04:00
Matt Green a182fda43f Add NotificationFilter tests 2016-10-29 09:37:50 -04:00
Matt Green ed865d9039 Linux: fix logspam from inotify's notification volume 2016-10-28 08:58:15 -04:00
Matt Green 672fd469a9 Reorder new() 2016-10-28 08:46:35 -04:00
Matt Green 4370d41e71 Make NotificationFilter immutable 2016-10-27 08:27:16 -04:00
Matt Green fdc31d4b02 Fix test 2016-10-26 16:29:34 -04:00
Matt Green e26eff226c Process module improvements, use later nix 2016-10-26 16:20:44 -04:00
Matt Green d14ccaaa1a Fix Windows warnings 2016-10-26 11:52:00 -04:00
Matt Green f04083a21d Use Process & ProcessReaper to handle async process waiting 2016-10-26 11:02:04 -04:00
Matt Green 1cc4d92345 PollWatcher sometimes reports directories with new/deleted files 2016-10-26 11:02:04 -04:00
Matt Green da46e3ffb5 Fix unused import warnings 2016-10-25 07:27:07 -04:00
Matt Green f7771a4480 Mark process tests as Unix-only for now 2016-10-25 07:19:41 -04:00
Matt Green 50e583ca8c Some tests for the Runner module 2016-10-25 07:05:53 -04:00
Matt Green 3d3915844a Improve runner API 2016-10-25 05:47:53 -04:00
Matt Green 918fd668a5 Polishing up process group handling and handling of unresponsive child processes 2016-10-24 21:49:12 -04:00
Matt Green d01da72e0b Forgot a #[cfg(unix)] marker on install() 2016-10-24 09:55:00 -04:00
Matt Green 0e0d14b475 Wait for FS activity to stop before proceeding; use interrupt handling 2016-10-24 09:53:06 -04:00
Matt Green d10b790c35 Use rustfmt to fix outstanding style issues 2016-10-23 20:12:48 -04:00
Matt Green 6a812d31b4 Extract CLI arg handling to args module 2016-10-23 20:07:48 -04:00
Matt Green 7b766b1f98 Drop signal crate in favor of nix 2016-10-23 15:15:28 -04:00
Matt Green f0d4a14e41 Fix Windows bugs relating to mutability 2016-10-22 17:05:43 -04:00
Matt Green 83b91e51d0 Refactor Runner a bit; add Drop impl for eventual use 2016-10-22 16:54:16 -04:00
Matt Green e67751bb56 Fix build errors on Windows 2016-10-22 15:51:17 -04:00
Matt Green 865b0b7d90 WIP: Add interrupt_handler module 2016-10-22 15:37:03 -04:00
Matt Green 1582240dbc Fix silly error 2016-10-20 14:30:05 -04:00
Matt Green 7d8f909220 Add watcher module, back to requiring nightly builds 2016-10-20 14:27:11 -04:00
Matt Green 03775b61ce No need to use before_exec() to call setpgid() 2016-10-20 12:09:51 -04:00
Matt Green b16cbec3ee Fix compile error on Windows 2016-10-20 11:50:25 -04:00
Matt Green f3c6df8845 Launch child processes in new process group 2016-10-20 11:38:51 -04:00
Matt Green 0a08d3f8ef Fix polling always being used 2016-10-20 10:07:55 -04:00
Matt Green 90d6659141 Add --force-poll option; closes #7 2016-10-19 20:19:01 -04:00
Matt Green a75dd49114 Set $WATCHEXEC_UPDATED_PATH to first changed path in child process;
closes #11
2016-10-19 19:40:50 -04:00
Matt Green 249e5a84e4 Search for .gitignore files in parent dirs; closes #10 2016-10-19 18:54:20 -04:00
Matt Green f1597cc1a6 Merge pull request #13 from palfrey/12-run-initially
Option to run command initially, before first file change
2016-10-18 18:05:14 -04:00
Tom Parker 7eabee9f40 Initial command run is outside the loop! 2016-10-18 22:36:12 +01:00