File tree 2 files changed +5
-5
lines changed
2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change 1
1
use std:: cell:: RefCell ;
2
2
use std:: collections:: HashMap ;
3
- use std:: fs;
4
3
use std:: path:: PathBuf ;
5
4
use std:: rc:: Rc ;
6
5
@@ -39,10 +38,9 @@ fn watch_json(
39
38
let path = args[ 0 ] . try_js_into :: < String > ( context) ?;
40
39
full_path. push ( path) ;
41
40
42
- let Ok ( canonical_path) = fs:: canonicalize ( & full_path) else { return Ok ( JsValue :: Undefined ) } ;
43
41
let callback = args[ 1 ] . try_js_into :: < JsFunction > ( context) ?;
44
42
// 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 ( ) ) ;
46
44
47
45
let run_first = match args. get ( 2 ) {
48
46
Some ( arg) => arg. try_js_into :: < bool > ( context) ?,
Original file line number Diff line number Diff line change @@ -185,13 +185,15 @@ impl SignWindowHandler {
185
185
pub fn new < P : AsRef < Path > > ( app_root : P ) -> Self {
186
186
let ( tx, rx) = mpsc:: channel ( ) ;
187
187
let tx_for_watcher = tx. clone ( ) ;
188
-
188
+
189
189
let mut watcher = notify:: recommended_watcher ( move |res : Result < notify:: Event , notify:: Error > | {
190
190
match res {
191
191
Ok ( event) => match event. kind {
192
192
notify:: EventKind :: Modify ( _) => {
193
193
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 ( ) ) ;
195
197
}
196
198
} ,
197
199
_ => ( ) ,
You can’t perform that action at this time.
0 commit comments