From 9416f975d3f405d1addfefbc4737c48f519bae77 Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Fri, 16 Apr 2021 09:44:53 +0300 Subject: [PATCH] fix(cli): set actual cli version in generated package.json --- cli/src/generate/binding_files.rs | 6 +++++- cli/src/generate/templates/package.json | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cli/src/generate/binding_files.rs b/cli/src/generate/binding_files.rs index 8ce7e4a4..8414b65d 100644 --- a/cli/src/generate/binding_files.rs +++ b/cli/src/generate/binding_files.rs @@ -11,6 +11,8 @@ const BUILD_RS_TEMPLATE: &'static str = include_str!("./templates/build.rs"); const CARGO_TOML_TEMPLATE: &'static str = include_str!("./templates/cargo.toml"); const PACKAGE_JSON_TEMPLATE: &'static str = include_str!("./templates/package.json"); const PARSER_NAME_PLACEHOLDER: &'static str = "PARSER_NAME"; +const CLI_VERSION_PLACEHOLDER: &'static str = "CLI_VERSION"; +const CLI_VERSION: &'static str = env!("CARGO_PKG_VERSION"); pub fn generate_binding_files(repo_path: &Path, language_name: &str) -> Result<()> { let bindings_dir = repo_path.join("bindings"); @@ -110,7 +112,9 @@ pub fn generate_binding_files(repo_path: &Path, language_name: &str) -> Result<( fn generate_file(path: &Path, template: &str, language_name: &str) -> Result<()> { write_file( path, - template.replace(PARSER_NAME_PLACEHOLDER, language_name), + template + .replace(PARSER_NAME_PLACEHOLDER, language_name) + .replace(CLI_VERSION_PLACEHOLDER, CLI_VERSION), ) } diff --git a/cli/src/generate/templates/package.json b/cli/src/generate/templates/package.json index bba22b82..18598797 100644 --- a/cli/src/generate/templates/package.json +++ b/cli/src/generate/templates/package.json @@ -11,7 +11,7 @@ "nan": "^2.12.1" }, "devDependencies": { - "tree-sitter-cli": "^0.17.3" + "tree-sitter-cli": "^CLI_VERSION" }, "scripts": { "test": "tree-sitter test"