Skip to content

Commit 2c18f66

Browse files
committed
Removed need to canonicalize paths to fix #15
1 parent 2cfaef1 commit 2c18f66

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Diff for: src/js_env/files.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::cell::RefCell;
22
use std::collections::HashMap;
3-
use std::fs;
43
use std::path::PathBuf;
54
use std::rc::Rc;
65

@@ -39,10 +38,9 @@ fn watch_json(
3938
let path = args[0].try_js_into::<String>(context)?;
4039
full_path.push(path);
4140

42-
let Ok(canonical_path) = fs::canonicalize(&full_path) else {return Ok(JsValue::Undefined)};
4341
let callback = args[1].try_js_into::<JsFunction>(context)?;
4442
// todo Keeping the callback outside the JsEnv seems to cause core dump on quit
45-
watches.borrow_mut().insert(canonical_path, callback.clone());
43+
watches.borrow_mut().insert(full_path.clone(), callback.clone());
4644

4745
let run_first = match args.get(2) {
4846
Some(arg) => arg.try_js_into::<bool>(context)?,

Diff for: src/window_handler.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,15 @@ impl SignWindowHandler {
185185
pub fn new<P: AsRef<Path>>(app_root: P) -> Self {
186186
let (tx, rx) = mpsc::channel();
187187
let tx_for_watcher = tx.clone();
188-
188+
189189
let mut watcher = notify::recommended_watcher(move |res: Result<notify::Event, notify::Error>| {
190190
match res {
191191
Ok(event) => match event.kind {
192192
notify::EventKind::Modify(_) => {
193193
for path_buf in event.paths {
194-
let _ = tx_for_watcher.send(path_buf);
194+
let cwd = std::env::current_dir().unwrap();
195+
let path = path_buf.strip_prefix(&cwd).unwrap();
196+
let _ = tx_for_watcher.send(path.to_owned());
195197
}
196198
},
197199
_ => (),

0 commit comments

Comments
 (0)