@@ -203,15 +203,20 @@ function printObjectDifference(objFrom, objTo, rawContent, parentKey = '') {
203
203
for ( const [ key , value ] of Object . entries ( objFrom ) ) {
204
204
const combinedKey = `${ parentKey } .${ key } `
205
205
if ( Array . isArray ( value ) && ! equalArray ( value , objTo [ key ] ) ) {
206
- console . log ( `In frontmatter key: ${ chalk . bold ( combinedKey ) } ` )
207
206
value . forEach ( ( entry , i ) => {
208
- if ( entry !== objTo [ key ] [ i ] ) {
209
- console . log ( chalk . red ( `- ${ entry } ` ) )
210
- console . log ( chalk . green ( `+ ${ objTo [ key ] [ i ] } ` ) )
211
- const needle = new RegExp ( `- ${ entry } \\b` )
212
- const index = rawContent . split ( / \n / g) . findIndex ( ( line ) => needle . test ( line ) )
213
- console . log ( ' ' , chalk . dim ( `line ${ ( index && index + 1 ) || 'unknown' } ` ) )
214
- console . log ( '' )
207
+ // If it was an array of objects, we need to go deeper!
208
+ if ( isObject ( entry ) ) {
209
+ printObjectDifference ( entry , objTo [ key ] [ i ] , rawContent , combinedKey )
210
+ } else {
211
+ console . log ( `In frontmatter key: ${ chalk . bold ( combinedKey ) } ` )
212
+ if ( entry !== objTo [ key ] [ i ] ) {
213
+ console . log ( chalk . red ( `- ${ entry } ` ) )
214
+ console . log ( chalk . green ( `+ ${ objTo [ key ] [ i ] } ` ) )
215
+ const needle = new RegExp ( `- ${ entry } \\b` )
216
+ const index = rawContent . split ( / \n / g) . findIndex ( ( line ) => needle . test ( line ) )
217
+ console . log ( ' ' , chalk . dim ( `line ${ ( index && index + 1 ) || 'unknown' } ` ) )
218
+ console . log ( '' )
219
+ }
215
220
}
216
221
} )
217
222
} else if ( typeof value === 'object' && value !== null ) {
0 commit comments