@@ -19,20 +19,45 @@ const denoDependencies = denoCargoToml.workspace.dependencies;
1919const localCargoTomlPath = rootDir . join ( "src/rs_lib/Cargo.toml" ) ;
2020const localCargoToml = toml . parse ( localCargoTomlPath . readTextSync ( ) ) as any ;
2121
22- for ( const [ key , value ] of Object . entries ( localCargoToml . dependencies ) ) {
23- const newVersion = getVersion ( denoDependencies [ key ] ) ;
24- if ( newVersion == null ) {
25- continue ;
22+ updateDependencies ( localCargoToml . dependencies , denoDependencies ) ;
23+
24+ // update target-specific dependencies
25+ if ( localCargoToml . target ) {
26+ for ( const targetDeps of Object . values ( localCargoToml . target ) ) {
27+ if (
28+ targetDeps != null &&
29+ typeof targetDeps === "object" &&
30+ "dependencies" in targetDeps
31+ ) {
32+ updateDependencies (
33+ ( targetDeps as any ) . dependencies ,
34+ denoDependencies ,
35+ ) ;
36+ }
2637 }
27- if ( typeof value === "string" ) {
28- if ( value !== newVersion ) {
29- $ . logLight ( `Updating ${ key } @${ value } to ${ newVersion } ` ) ;
30- localCargoToml . dependencies [ key ] = newVersion ;
38+ }
39+
40+ function updateDependencies (
41+ localDeps : Record < string , any > ,
42+ sourceDeps : Record < string , any > ,
43+ ) {
44+ for ( const [ key , value ] of Object . entries ( localDeps ) ) {
45+ const newVersion = getVersion ( sourceDeps [ key ] ) ;
46+ if ( newVersion == null ) {
47+ continue ;
3148 }
32- } else if ( value != null && typeof value === "object" && "version" in value ) {
33- if ( value . version !== newVersion ) {
34- $ . logLight ( `Updating ${ key } @${ value . version } to ${ newVersion } ` ) ;
35- value . version = newVersion ;
49+ if ( typeof value === "string" ) {
50+ if ( value !== newVersion ) {
51+ $ . logLight ( `Updating ${ key } @${ value } to ${ newVersion } ` ) ;
52+ localDeps [ key ] = newVersion ;
53+ }
54+ } else if (
55+ value != null && typeof value === "object" && "version" in value
56+ ) {
57+ if ( value . version !== newVersion ) {
58+ $ . logLight ( `Updating ${ key } @${ value . version } to ${ newVersion } ` ) ;
59+ value . version = newVersion ;
60+ }
3661 }
3762 }
3863}
0 commit comments