Skip to content

Commit

Permalink
Improve event comparison (#13)
Browse files Browse the repository at this point in the history
* Improve event comparison

* Ignore duplicate events
  • Loading branch information
GavinFigueroa authored and billimek committed Oct 11, 2019
1 parent 7540ece commit 6a0bf66
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bin/out
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ stdin.on('end', function () {
const source = resourceConfig.source || {};
const params = resourceConfig.params || {};

// Remove duplicates
params.events = [...new Set(params.events)];

processWebhook(source, params);
});

Expand Down Expand Up @@ -60,7 +63,7 @@ async function processWebhook(source, params) {
case 'create':
if (existingHook == null) {
createWebhook(webhookEndpoint, 'POST', source.github_token, body);
} else if (existingHook.events !== body.events) {
} else if (!_.isEqual(_.sortBy(existingHook.events), _.sortBy(body.events))) {
updateWebhook(`${webhookEndpoint}/${existingHook.id}`, 'PATCH', source.github_token, body)
} else {
log('Webhook already exists');
Expand Down

0 comments on commit 6a0bf66

Please sign in to comment.