From 098675516b9e69299050b346283e9e4a1465d0e4 Mon Sep 17 00:00:00 2001 From: Juan Picado Date: Thu, 13 Apr 2017 21:32:49 +0200 Subject: [PATCH] #144 Add fallback support to previous config files --- lib/notify.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/notify.js b/lib/notify.js index 9faceeb7..c0658d0d 100644 --- a/lib/notify.js +++ b/lib/notify.js @@ -13,7 +13,18 @@ module.exports.notify = function(metadata, config) { body: content } - if ( config.notify.headers ) { + // provides fallback support, it's accept an Object {} and Array of {} + if ( config.notify.headers && Array.isArray(config.notify.headers) ) { + var header = {}; + config.notify.headers.map(function(item) { + if (Object.is(item, item)) { + for (var key in item) { + header[key] = item[key]; + } + } + }); + options.headers = header; + } else if (Object.is(config.notify.headers, config.notify.headers)) { options.headers = config.notify.headers; }