1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-26 16:09:27 -05:00

perf(cli): avoid canonicalize_path if config file does not exist (#15957)

This commit is contained in:
Divy Srivastava 2022-09-19 19:31:47 +05:30 committed by David Sherret
parent 1e8f4a1c40
commit 34d351ac1d

View file

@ -525,6 +525,20 @@ impl ConfigFile {
std::env::current_dir()?.join(path_ref)
};
// perf: Check if the config file exists before canonicalizing path.
if !config_file.exists() {
return Err(
std::io::Error::new(
std::io::ErrorKind::InvalidInput,
format!(
"Could not find the config file: {}",
config_file.to_string_lossy()
),
)
.into(),
);
}
let config_path = canonicalize_path(&config_file).map_err(|_| {
std::io::Error::new(
std::io::ErrorKind::InvalidInput,