Skip to content

Commit

Permalink
Print combined key only once (github#35549)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe authored Mar 14, 2023
1 parent 0536e63 commit 3e0dd71
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion script/update-internal-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,17 @@ function printObjectDifference(objFrom, objTo, rawContent, parentKey = '') {
for (const [key, value] of Object.entries(objFrom)) {
const combinedKey = `${parentKey}.${key}`
if (Array.isArray(value) && !equalArray(value, objTo[key])) {
const printedKeys = new Set()
value.forEach((entry, i) => {
// If it was an array of objects, we need to go deeper!
if (isObject(entry)) {
printObjectDifference(entry, objTo[key][i], rawContent, combinedKey)
} else {
console.log(`In frontmatter key: ${chalk.bold(combinedKey)}`)
if (entry !== objTo[key][i]) {
if (!printedKeys.has(combinedKey)) {
console.log(`In frontmatter key: ${chalk.bold(combinedKey)}`)
printedKeys.add(combinedKey)
}
console.log(chalk.red(`- ${entry}`))
console.log(chalk.green(`+ ${objTo[key][i]}`))
const needle = new RegExp(`- ${entry}\\b`)
Expand Down

0 comments on commit 3e0dd71

Please sign in to comment.