From f9a4e8ecdcbe64c9692e9f9dd18058b17d52e9df Mon Sep 17 00:00:00 2001 From: ObserverOfTime Date: Wed, 16 Oct 2024 17:19:52 +0300 Subject: [PATCH] fix(init): use current path if unspecified --- cli/loader/src/lib.rs | 5 +++-- cli/src/init.rs | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cli/loader/src/lib.rs b/cli/loader/src/lib.rs index a63644a6..c827243f 100644 --- a/cli/loader/src/lib.rs +++ b/cli/loader/src/lib.rs @@ -164,7 +164,8 @@ pub struct Grammar { #[serde(skip_serializing_if = "Option::is_none")] pub camelcase: Option, pub scope: String, - pub path: PathBuf, + #[serde(skip_serializing_if = "Option::is_none")] + pub path: Option, #[serde(default, skip_serializing_if = "PathsJSON::is_empty")] pub external_files: PathsJSON, pub file_types: Option>, @@ -1114,7 +1115,7 @@ impl Loader { // Determine the path to the parser directory. This can be specified in // the tree-sitter.json, but defaults to the directory containing the // tree-sitter.json. - let language_path = parser_path.join(grammar.path); + let language_path = parser_path.join(grammar.path.unwrap_or(PathBuf::from("."))); // Determine if a previous language configuration in this package.json file // already uses the same language. diff --git a/cli/src/init.rs b/cli/src/init.rs index 5837747b..c6ce2746 100644 --- a/cli/src/init.rs +++ b/cli/src/init.rs @@ -137,7 +137,7 @@ impl JsonConfigOpts { name: self.name.clone(), camelcase: Some(self.camelcase), scope: self.scope, - path: PathBuf::from("."), + path: None, external_files: PathsJSON::Empty, file_types: None, highlights: PathsJSON::Empty, @@ -234,7 +234,7 @@ pub fn migrate_package_json(repo_path: &Path) -> Result { name: name.clone(), camelcase: Some(name.to_upper_camel_case()), scope: l.scope.unwrap_or_else(|| format!("source.{name}")), - path: l.path, + path: Some(l.path), external_files: l.external_files, file_types: l.file_types, highlights: l.highlights,