-
Notifications
You must be signed in to change notification settings - Fork 82
Conversation
Many functions were removed by inlining them into their calling function. Unnecessary function splitting has lead to many small functions that don't need to be seperated. As a result the code should be shorter and less spammed with function declarations. A few different things were done, too: - the regexes for ignored filenames are not compiled every time a file changes anymore - some expressions were simplified to shrink the code - some things were renamed to match a more idiomatic naming scheme - comments were added Important: Currently the feature of waiting 2 seconds before starting a new compile is removed! It is planned to be replaced by a better way of scheduling. However, this was not yet implemented. This can lead to excessive process spawning when many files change in a short time. Do not use in production!
|
||
// TODO: check if another command is still running! | ||
let _ = thread::spawn(move || { | ||
debug!("Starting a compile"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This made sense in the original implementation which could only compile, but now should probably be changed to Starting a command run!
or something more appropriate.
pub const MAX_ANCESTORS: u32 = 10; | ||
|
||
/// Which subdirectories are being watched for changes | ||
pub const WATCH_DIRS: [&'static str; 3] = ["src", "tests", "benches"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#33 could just be fixed right there, while we're at it.
LGTM so far. |
LGTM |
Ok, that should work. Normal running cargo commands, like Also: it might be desirable to also kill Another note: it doesn't immediately help with webservers, since killing a process doesn't immediately free it's used ports. Will try more about that later. Last note: I haven't done profiling of CPU usage due to "busy" timeout waiting yet, but I expect it to be unnoticeable. |
println!("$ cargo {}", command); | ||
|
||
// Update global information about the running job | ||
if args.get(0) == Some(&"run") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this catch commands such as cargo run -- --some-option
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already split on whitespace, right? I figured it should be pretty safe. I don't see when this wouldn't work.
In your example, the original call would be cargo watch "run -- --some-option"
. This would mean that command
would be run -- --some-option
. Whitespace-split is ["run", "--", "--some-option"]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, true.
Thanks for everything! All merged and released as v3.1.0! |
This PR is based on #29. For more details about the changes, see the commit messages.
Important: This is still lacking one critical feature. I re-add this feature, when we have decided how to implement it. For discussion see #25. So: Do not merge this PR yet ;)