Skip to content

Instantly share code, notes, and snippets.

@hendrixroa
Created March 1, 2023 02:08
Show Gist options
  • Save hendrixroa/8acab17c826c1dbeb0dc7790e73692d7 to your computer and use it in GitHub Desktop.
Save hendrixroa/8acab17c826c1dbeb0dc7790e73692d7 to your computer and use it in GitHub Desktop.
private async sendSlackMessage(countVulnerabilities: number, packageName: string): Promise<void> {
const postData = {
attachments: [
{
author_name: 'YARN - AUDIT',
color: '#ff0000',
mrkdwn_in: ['text', 'pretext'],
text: `Found *${countVulnerabilities}* vulnerabilities in _${packageName}_ project, for more details run _yarn audit_`,
},
],
channel: `#packages-vulnerabilities`,
icon_emoji: ':warning:',
mrkdwn: true,
username: 'YARN Audit Alert',
};
const result = await this.client.post('', {
body: postData,
});
if (!result.ok) {
throw new Error('The message cannot be delivered');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment