From 1cc7a04c89bd233643dfe52385d8cb7b0f5390e7 Mon Sep 17 00:00:00 2001 From: Rohit Gohri Date: Wed, 3 Apr 2019 14:26:29 +0530 Subject: [PATCH] fix error not getting added and fix resending --- index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index b9cfc85..2df2635 100644 --- a/index.js +++ b/index.js @@ -42,9 +42,9 @@ function getSlackConf() { } /** - * @returns {attach} + * @returns {attach[]} */ -function getDefaultAttachment() { +function getDefaultAttachments() { const {name, version} = getPackageInfo(); const fields = [ { @@ -72,9 +72,9 @@ function getDefaultAttachment() { }); } - return { + return [{ fields, - }; + }]; } class Slack { @@ -118,7 +118,7 @@ class Slack { */ attachment(attachments) { if (!Array.isArray(attachments)) attachments = [attachments]; - this._attachments.concat(attachments); + this._attachments = this._attachments.concat(attachments); return this; } @@ -229,12 +229,12 @@ class Slack { attachments = [], extraProps = {}, } = {}) { - attachments.push(getDefaultAttachment()); + const finalAttachments = attachments.concat(getDefaultAttachments()); const message = Object.assign(extraProps, { text, channel, username: this.username, - attachments: JSON.stringify(attachments), + attachments: JSON.stringify(finalAttachments), }); if (this.logCondition()) {