@@ -48,25 +48,21 @@ pub fn claude_md_has_vox(content: &str) -> bool {
4848
4949/// Checks whether a parsed settings.json already has a vox hook.
5050pub fn has_vox_hook ( settings : & Value ) -> bool {
51- if let Some ( hooks) = settings. get ( "hooks" ) {
52- if let Some ( stop) = hooks. get ( "Stop" ) {
53- if let Some ( arr) = stop. as_array ( ) {
51+ if let Some ( hooks) = settings. get ( "hooks" )
52+ && let Some ( stop) = hooks. get ( "Stop" )
53+ && let Some ( arr) = stop. as_array ( ) {
5454 for entry in arr {
55- if let Some ( inner_hooks) = entry. get ( "hooks" ) {
56- if let Some ( inner_arr) = inner_hooks. as_array ( ) {
55+ if let Some ( inner_hooks) = entry. get ( "hooks" )
56+ && let Some ( inner_arr) = inner_hooks. as_array ( ) {
5757 for h in inner_arr {
58- if let Some ( cmd) = h. get ( "command" ) . and_then ( |c| c. as_str ( ) ) {
59- if cmd. starts_with ( "vox " ) {
58+ if let Some ( cmd) = h. get ( "command" ) . and_then ( |c| c. as_str ( ) )
59+ && cmd. starts_with ( "vox " ) {
6060 return true ;
6161 }
62- }
6362 }
6463 }
65- }
6664 }
6765 }
68- }
69- }
7066 false
7167}
7268
@@ -100,8 +96,8 @@ pub fn build_settings(existing: Option<&str>) -> Result<String> {
10096 }
10197
10298 // Merge hooks
103- if let Some ( new_hooks) = vox_hook. get ( "hooks" ) {
104- if let Some ( new_stop) = new_hooks. get ( "Stop" ) {
99+ if let Some ( new_hooks) = vox_hook. get ( "hooks" )
100+ && let Some ( new_stop) = new_hooks. get ( "Stop" ) {
105101 let base_obj = base
106102 . as_object_mut ( )
107103 . context ( "settings.json is not an object" ) ?;
@@ -115,13 +111,11 @@ pub fn build_settings(existing: Option<&str>) -> Result<String> {
115111 let stop_arr = hooks_map
116112 . entry ( "Stop" )
117113 . or_insert_with ( || Value :: Array ( vec ! [ ] ) ) ;
118- if let Some ( arr) = stop_arr. as_array_mut ( ) {
119- if let Some ( new_entries) = new_stop. as_array ( ) {
114+ if let Some ( arr) = stop_arr. as_array_mut ( )
115+ && let Some ( new_entries) = new_stop. as_array ( ) {
120116 arr. extend ( new_entries. clone ( ) ) ;
121117 }
122- }
123118 }
124- }
125119
126120 base
127121 }
0 commit comments