From 6a0bf665eba8b3acb2c4644990cca23f79ddd0b5 Mon Sep 17 00:00:00 2001 From: GavinFigueroa Date: Fri, 11 Oct 2019 09:12:18 -0400 Subject: [PATCH] Improve event comparison (#13) * Improve event comparison * Ignore duplicate events --- bin/out | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/out b/bin/out index 8de8658..dbf318f 100755 --- a/bin/out +++ b/bin/out @@ -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); }); @@ -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');