UNPKG

1.16 kBJavaScriptView Raw
1#!/usr/bin/env node
2"use strict";
3Object.defineProperty(exports, "__esModule", { value: true });
4const yargs = require("yargs");
5const __1 = require("..");
6const script_1 = require("../script");
7script_1.runScript(async () => {
8 const { channel, msg, username, emoji, webhook: webhookUrl, } = yargs.options({
9 channel: {
10 type: 'string',
11 demandOption: true,
12 },
13 msg: {
14 type: 'string',
15 demandOption: true,
16 },
17 username: {
18 type: 'string',
19 default: 'bot',
20 },
21 emoji: {
22 type: 'string',
23 default: ':spider_web:',
24 },
25 webhook: {
26 type: 'string',
27 default: process.env.SLACK_WEBHOOK_URL,
28 },
29 }).argv;
30 if (!webhookUrl) {
31 console.log(`Slack webhook is required, either via env.SLACK_WEBHOOK_URL or --webhook`);
32 process.exit(1);
33 }
34 const slack = new __1.SlackService({
35 webhookUrl,
36 });
37 await slack.send({
38 items: msg,
39 channel,
40 username,
41 icon_emoji: emoji,
42 throwOnError: true,
43 });
44});