mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-28 22:21:33 +02:00
Merge pull request #74 from jaemk/fix_panic
don't panic on missing folder
This commit is contained in:
commit
5461c6ff1b
@ -1,6 +1,7 @@
|
||||
extern crate watchexec;
|
||||
use watchexec::{cli, run};
|
||||
use std::error::Error;
|
||||
|
||||
fn main() {
|
||||
run(cli::get_args());
|
||||
fn main() -> Result<(), Box<Error>> {
|
||||
run(cli::get_args())
|
||||
}
|
||||
|
14
src/run.rs
14
src/run.rs
@ -16,6 +16,8 @@ use signal::{self, Signal};
|
||||
use watcher::{Event, Watcher};
|
||||
use pathop::PathOp;
|
||||
|
||||
type Result<T> = ::std::result::Result<T, Box<::std::error::Error>>;
|
||||
|
||||
fn init_logger(debug: bool) {
|
||||
let mut log_builder = env_logger::Builder::new();
|
||||
let level = if debug {
|
||||
@ -46,7 +48,7 @@ fn should_switch_to_poll(_: &Error) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn run(args: cli::Args) {
|
||||
pub fn run(args: cli::Args) -> Result<()> {
|
||||
let child_process: Arc<RwLock<Option<Process>>> = Arc::new(RwLock::new(None));
|
||||
let weak_child = Arc::downgrade(&child_process);
|
||||
|
||||
@ -67,15 +69,16 @@ pub fn run(args: cli::Args) {
|
||||
|
||||
init_logger(args.debug);
|
||||
|
||||
let paths: Vec<PathBuf> = args.paths
|
||||
let paths: Result<Vec<PathBuf>> = args.paths
|
||||
.iter()
|
||||
.map(|p| {
|
||||
Path::new(&p)
|
||||
Ok(Path::new(&p)
|
||||
.canonicalize()
|
||||
.expect(&format!("unable to canonicalize \"{}\"", &p))
|
||||
.to_owned()
|
||||
.map_err(|e| format!("Unable to canonicalize path: \"{}\", {}", p, e))?
|
||||
.to_owned())
|
||||
})
|
||||
.collect();
|
||||
let paths = paths?;
|
||||
|
||||
let gitignore = if !args.no_vcs_ignore {
|
||||
gitignore::load(&paths)
|
||||
@ -198,6 +201,7 @@ pub fn run(args: cli::Args) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn wait_fs(rx: &Receiver<Event>, filter: &NotificationFilter, debounce: u64) -> Vec<PathOp> {
|
||||
|
Loading…
Reference in New Issue
Block a user