mirror of
https://github.com/denoland/deno.git
synced 2025-03-04 01:44:26 -05:00
fix(watcher): keep working even when imported file has invalid syntax (#9091)
This commit is contained in:
parent
f18ae461a8
commit
5c6ab75de1
2 changed files with 20 additions and 2 deletions
|
@ -172,7 +172,7 @@ where
|
||||||
let mut debounce = Debounce::new();
|
let mut debounce = Debounce::new();
|
||||||
// Store previous data. If module resolution fails at some point, the watcher will try to
|
// Store previous data. If module resolution fails at some point, the watcher will try to
|
||||||
// continue watching files using these data.
|
// continue watching files using these data.
|
||||||
let mut paths;
|
let mut paths = Vec::new();
|
||||||
let mut module = None;
|
let mut module = None;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
@ -185,7 +185,10 @@ where
|
||||||
module = Some(module_info);
|
module = Some(module_info);
|
||||||
}
|
}
|
||||||
ModuleResolutionResult::Fail { source_path, error } => {
|
ModuleResolutionResult::Fail { source_path, error } => {
|
||||||
|
if paths.is_empty() {
|
||||||
paths = vec![source_path];
|
paths = vec![source_path];
|
||||||
|
}
|
||||||
|
|
||||||
if module.is_none() {
|
if module.is_none() {
|
||||||
eprintln!("{}: {}", colors::red_bold("error"), error);
|
eprintln!("{}: {}", colors::red_bold("error"), error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1571,6 +1571,21 @@ fn run_watch() {
|
||||||
assert!(stdout_lines.next().unwrap().contains("42"));
|
assert!(stdout_lines.next().unwrap().contains("42"));
|
||||||
wait_for_process_finished("Process", &mut stderr_lines);
|
wait_for_process_finished("Process", &mut stderr_lines);
|
||||||
|
|
||||||
|
// Update the content of the imported file with invalid syntax
|
||||||
|
std::fs::write(&another_file, "syntax error ^^").expect("error writing file");
|
||||||
|
std::thread::sleep(std::time::Duration::from_secs(1));
|
||||||
|
assert!(stderr_lines.next().unwrap().contains("Restarting"));
|
||||||
|
assert!(stderr_lines.next().unwrap().contains("error:"));
|
||||||
|
wait_for_process_finished("Process", &mut stderr_lines);
|
||||||
|
|
||||||
|
// Modify the imported file and make sure that restarting occurs
|
||||||
|
std::fs::write(&another_file, "export const foo = 'modified!';")
|
||||||
|
.expect("error writing file");
|
||||||
|
std::thread::sleep(std::time::Duration::from_secs(1));
|
||||||
|
assert!(stderr_lines.next().unwrap().contains("Restarting"));
|
||||||
|
assert!(stdout_lines.next().unwrap().contains("modified!"));
|
||||||
|
wait_for_process_finished("Process", &mut stderr_lines);
|
||||||
|
|
||||||
// the watcher process is still alive
|
// the watcher process is still alive
|
||||||
assert!(child.try_wait().unwrap().is_none());
|
assert!(child.try_wait().unwrap().is_none());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue