Skip to content

Commit a69069c

Browse files
committed
fix(docs.rs): handling ~ correctly in watching fns
1 parent 129be9f commit a69069c

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/docs.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,19 @@ pub mod runners {
6666
exit(1);
6767
}
6868
};
69-
let path: String = if cfg!(windows) {
70-
String::from(matches.value_of("INPUT").unwrap())
71-
} else {
72-
matches
73-
.value_of("INPUT")
69+
let path: String = if matches.value_of("INPUT").unwrap().contains('~') {
70+
home_dir()
71+
.expect("Could not find home directory.")
72+
.join(
73+
Path::new(matches.value_of("INPUT").unwrap())
74+
.strip_prefix("~")
75+
.expect("Could not strip shortcut."),
76+
)
77+
.to_str()
7478
.unwrap()
75-
.replace("~", home_dir().unwrap().to_str().unwrap())
79+
.to_string()
80+
} else {
81+
String::from(matches.value_of("INPUT").unwrap())
7682
};
7783
watcher.watch(&path, RecursiveMode::Recursive).unwrap();
7884
println!("Watching for changes in {}...", path);

0 commit comments

Comments
 (0)