@@ -4,7 +4,6 @@ use anyhow::{anyhow, Result};
44use git2:: { DiffOptions , Repository } ;
55use indoc:: indoc;
66use semver:: { BuildMetadata , Prerelease , Version } ;
7- use toml:: Value ;
87
98use crate :: { create_commit, BumpVersion } ;
109
@@ -241,7 +240,7 @@ fn update_crates(current_version: &Version, next_version: &Version) -> Result<()
241240 . arg ( "--force" )
242241 . arg ( "tree-sitter{,-cli,-config,-generate,-loader,-highlight,-tags}" )
243242 . arg ( "--ignore-changes" )
244- . arg ( "lib /language/*" ) ;
243+ . arg ( "crates /language/*" ) ;
245244
246245 let status = cmd. status ( ) ?;
247246
@@ -253,7 +252,10 @@ fn update_crates(current_version: &Version, next_version: &Version) -> Result<()
253252}
254253
255254fn update_npm ( next_version : & Version ) -> Result < ( ) > {
256- for path in [ "lib/binding_web/package.json" , "cli/npm/package.json" ] {
255+ for path in [
256+ "lib/binding_web/package.json" ,
257+ "crates/cli/npm/package.json" ,
258+ ] {
257259 let package_json =
258260 serde_json:: from_str :: < serde_json:: Value > ( & std:: fs:: read_to_string ( path) ?) ?;
259261
@@ -275,13 +277,11 @@ fn update_npm(next_version: &Version) -> Result<()> {
275277}
276278
277279fn update_zig ( next_version : & Version ) -> Result < ( ) > {
278- let zig = std:: fs:: read_to_string ( "build.zig.zon" ) ?;
279-
280- let zig = zig
280+ let zig = std:: fs:: read_to_string ( "build.zig.zon" ) ?
281281 . lines ( )
282282 . map ( |line| {
283- if line. starts_with ( " .version" ) {
284- format ! ( " .version = \" {next_version}\" ," )
283+ if line. starts_with ( " .version" ) {
284+ format ! ( " .version = \" {next_version}\" ," )
285285 } else {
286286 line. to_string ( )
287287 }
@@ -297,11 +297,13 @@ fn update_zig(next_version: &Version) -> Result<()> {
297297
298298/// read Cargo.toml and get the version
299299fn fetch_workspace_version ( ) -> Result < String > {
300- let cargo_toml = toml:: from_str :: < Value > ( & std:: fs:: read_to_string ( "Cargo.toml" ) ?) ?;
301-
302- Ok ( cargo_toml[ "workspace" ] [ "package" ] [ "version" ]
303- . as_str ( )
304- . unwrap ( )
305- . trim_matches ( '"' )
306- . to_string ( ) )
300+ std:: fs:: read_to_string ( "Cargo.toml" ) ?
301+ . lines ( )
302+ . find ( |line| line. starts_with ( "version = " ) )
303+ . and_then ( |line| {
304+ line. split_terminator ( '"' )
305+ . next_back ( )
306+ . map ( |s| s. to_string ( ) )
307+ } )
308+ . ok_or_else ( || anyhow ! ( "No version found in Cargo.toml" ) )
307309}
0 commit comments