Skip to content

Commit

Permalink
fix: don't print deprecation warning for deleteNode for the sample pl…
Browse files Browse the repository at this point in the history
…ugin multiple times (#29746)
  • Loading branch information
pieh authored Feb 25, 2021
1 parent 5fb6064 commit 66477f1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/gatsby/src/redux/actions/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,8 @@ ${reservedFields.map(f => ` * "${f}"`).join(`\n`)}
}
}

const deleteNodeDeprecationWarningDisplayedMessages = new Set()

/**
* Delete a node
* @param {object} node A node object. See the "createNode" action for more information about the node object details.
Expand All @@ -441,7 +443,10 @@ actions.deleteNode = (node: any, plugin?: Plugin) => {
if (plugin && plugin.name) {
msg = msg + ` "deleteNode" was called by ${plugin.name}`
}
report.warn(msg)
if (!deleteNodeDeprecationWarningDisplayedMessages.has(msg)) {
report.warn(msg)
deleteNodeDeprecationWarningDisplayedMessages.add(msg)
}

id = node.node.id
} else {
Expand Down

0 comments on commit 66477f1

Please sign in to comment.