UNPKG

@naturalcycles/nodejs-lib

Version:
45 lines (44 loc) 1.16 kB
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const yargs = require("yargs"); const __1 = require(".."); const script_1 = require("../script"); (0, script_1.runScript)(async () => { const { channel, msg, username, emoji, webhook: webhookUrl, } = yargs.options({ channel: { type: 'string', demandOption: true, }, msg: { type: 'string', demandOption: true, }, username: { type: 'string', default: 'bot', }, emoji: { type: 'string', default: ':spider_web:', }, webhook: { type: 'string', default: process.env.SLACK_WEBHOOK_URL, }, }).argv; if (!webhookUrl) { console.log(`Slack webhook is required, either via env.SLACK_WEBHOOK_URL or --webhook`); process.exit(1); } const slack = new __1.SlackService({ webhookUrl, }); await slack.send({ items: msg, channel, username, icon_emoji: emoji, throwOnError: true, }); });