fix(cli): Avoid ENOENT if config.json is not in TREE_SITTER_DIR

Fixes #1222.
This commit is contained in:
Vladimir Panteleev 2021-07-01 20:58:23 +00:00
parent af675f5426
commit 09e2e9fe87
No known key found for this signature in database
GPG key ID: 5004F0FAD051576D

View file

@ -24,7 +24,9 @@ impl Config {
if let Ok(path) = env::var("TREE_SITTER_DIR") {
let mut path = PathBuf::from(path);
path.push("config.json");
return Ok(Some(path));
if path.is_file() {
return Ok(Some(path));
}
}
let xdg_path = Self::xdg_config_file()?;