mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix(fmt/lint): strip unc paths on Windows when displaying file paths in lint and fmt (#12606)
This commit is contained in:
parent
b92019a847
commit
2794d0b7a2
3 changed files with 16 additions and 14 deletions
|
@ -1,6 +1,8 @@
|
|||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use crate::colors;
|
||||
use crate::fs_util::canonicalize_path;
|
||||
|
||||
use deno_core::error::AnyError;
|
||||
use deno_core::futures::stream::{Stream, StreamExt};
|
||||
use deno_core::futures::Future;
|
||||
|
@ -231,7 +233,7 @@ fn new_watcher(
|
|||
let paths = event
|
||||
.paths
|
||||
.iter()
|
||||
.filter_map(|path| path.canonicalize().ok());
|
||||
.filter_map(|path| canonicalize_path(path).ok());
|
||||
let mut changed_paths = changed_paths.lock();
|
||||
changed_paths.extend(paths);
|
||||
}
|
||||
|
|
|
@ -233,14 +233,14 @@ where
|
|||
// retain only the paths which exist and ignore the rest
|
||||
let canonicalized_ignore: Vec<PathBuf> = ignore
|
||||
.iter()
|
||||
.filter_map(|i| i.canonicalize().ok())
|
||||
.filter_map(|i| canonicalize_path(i).ok())
|
||||
.collect();
|
||||
|
||||
for file in files {
|
||||
for entry in WalkDir::new(file)
|
||||
.into_iter()
|
||||
.filter_entry(|e| {
|
||||
e.path().canonicalize().map_or(false, |c| {
|
||||
canonicalize_path(e.path()).map_or(false, |c| {
|
||||
!canonicalized_ignore.iter().any(|i| c.starts_with(i))
|
||||
})
|
||||
})
|
||||
|
@ -249,7 +249,7 @@ where
|
|||
_ => None,
|
||||
})
|
||||
{
|
||||
target_files.push(entry.into_path().canonicalize()?)
|
||||
target_files.push(canonicalize_path(entry.path())?)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ fn lint_watch_test() {
|
|||
|
||||
let mut output = read_all_lints(&mut stderr_lines);
|
||||
let expected = std::fs::read_to_string(badly_linted_output).unwrap();
|
||||
assert_eq!(expected, output);
|
||||
assert_eq!(output, expected);
|
||||
|
||||
// Change content of the file again to be badly-linted1
|
||||
std::fs::copy(&badly_linted_fixed1, &badly_linted)
|
||||
|
@ -125,7 +125,7 @@ fn lint_watch_test() {
|
|||
|
||||
output = read_all_lints(&mut stderr_lines);
|
||||
let expected = std::fs::read_to_string(badly_linted_fixed1_output).unwrap();
|
||||
assert_eq!(expected, output);
|
||||
assert_eq!(output, expected);
|
||||
|
||||
// Change content of the file again to be badly-linted1
|
||||
std::fs::copy(&badly_linted_fixed2, &badly_linted)
|
||||
|
@ -134,7 +134,7 @@ fn lint_watch_test() {
|
|||
|
||||
output = read_all_lints(&mut stderr_lines);
|
||||
let expected = std::fs::read_to_string(badly_linted_fixed2_output).unwrap();
|
||||
assert_eq!(expected, output);
|
||||
assert_eq!(output, expected);
|
||||
|
||||
// the watcher process is still alive
|
||||
assert!(child.try_wait().unwrap().is_none());
|
||||
|
@ -182,7 +182,7 @@ fn lint_watch_without_args_test() {
|
|||
|
||||
let mut output = read_all_lints(&mut stderr_lines);
|
||||
let expected = std::fs::read_to_string(badly_linted_output).unwrap();
|
||||
assert_eq!(expected, output);
|
||||
assert_eq!(output, expected);
|
||||
|
||||
// Change content of the file again to be badly-linted1
|
||||
std::fs::copy(&badly_linted_fixed1, &badly_linted)
|
||||
|
@ -191,7 +191,7 @@ fn lint_watch_without_args_test() {
|
|||
|
||||
output = read_all_lints(&mut stderr_lines);
|
||||
let expected = std::fs::read_to_string(badly_linted_fixed1_output).unwrap();
|
||||
assert_eq!(expected, output);
|
||||
assert_eq!(output, expected);
|
||||
|
||||
// Change content of the file again to be badly-linted1
|
||||
std::fs::copy(&badly_linted_fixed2, &badly_linted)
|
||||
|
@ -200,7 +200,7 @@ fn lint_watch_without_args_test() {
|
|||
|
||||
output = read_all_lints(&mut stderr_lines);
|
||||
let expected = std::fs::read_to_string(badly_linted_fixed2_output).unwrap();
|
||||
assert_eq!(expected, output);
|
||||
assert_eq!(output, expected);
|
||||
|
||||
// the watcher process is still alive
|
||||
assert!(child.try_wait().unwrap().is_none());
|
||||
|
@ -285,7 +285,7 @@ fn fmt_watch_test() {
|
|||
|
||||
let expected = std::fs::read_to_string(fixed.clone()).unwrap();
|
||||
let actual = std::fs::read_to_string(badly_formatted.clone()).unwrap();
|
||||
assert_eq!(expected, actual);
|
||||
assert_eq!(actual, expected);
|
||||
|
||||
// Change content of the file again to be badly formatted
|
||||
std::fs::copy(&badly_formatted_original, &badly_formatted).unwrap();
|
||||
|
@ -294,7 +294,7 @@ fn fmt_watch_test() {
|
|||
// Check if file has been automatically formatted by watcher
|
||||
let expected = std::fs::read_to_string(fixed).unwrap();
|
||||
let actual = std::fs::read_to_string(badly_formatted).unwrap();
|
||||
assert_eq!(expected, actual);
|
||||
assert_eq!(actual, expected);
|
||||
check_alive_then_kill(child);
|
||||
}
|
||||
|
||||
|
@ -325,7 +325,7 @@ fn fmt_watch_without_args_test() {
|
|||
|
||||
let expected = std::fs::read_to_string(fixed.clone()).unwrap();
|
||||
let actual = std::fs::read_to_string(badly_formatted.clone()).unwrap();
|
||||
assert_eq!(expected, actual);
|
||||
assert_eq!(actual, expected);
|
||||
|
||||
// Change content of the file again to be badly formatted
|
||||
std::fs::copy(&badly_formatted_original, &badly_formatted).unwrap();
|
||||
|
@ -334,7 +334,7 @@ fn fmt_watch_without_args_test() {
|
|||
// Check if file has been automatically formatted by watcher
|
||||
let expected = std::fs::read_to_string(fixed).unwrap();
|
||||
let actual = std::fs::read_to_string(badly_formatted).unwrap();
|
||||
assert_eq!(expected, actual);
|
||||
assert_eq!(actual, expected);
|
||||
check_alive_then_kill(child);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue