Skip to content
This repository has been archived by the owner on May 31, 2023. It is now read-only.

Commit

Permalink
feat(notify): allow send with all email services
Browse files Browse the repository at this point in the history
  • Loading branch information
colinmeinke committed Sep 25, 2018
1 parent 6facfb8 commit e7462e1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions commands/notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ const inquirer = require('inquirer')
const nodemailer = require('nodemailer')

const notifications = [
{
subject: 'Hello world!',
message: `Nice to meet you!`,
},
{
subject: 'Reminder: production changes',
message: `It is important to remember that changes that have even the slightest chance of causing errors, should not be run directly on a production server (at least without testing somewhere else first).
Expand All @@ -11,7 +15,7 @@ This includes changes such as:
- updating plugins
- changing config
- etc.`,
}
},
]

module.exports = (team, email) => {
Expand All @@ -28,7 +32,7 @@ module.exports = (team, email) => {
type: 'list',
name: 'service',
message: 'How would you like to notify them?',
choices: [ 'Email' ],
choices: email.map(({ name }) => `Email (${name})`),
},
{
type: 'list',
Expand All @@ -40,7 +44,9 @@ module.exports = (team, email) => {
.then(({ name, service, subject }) => {
console.log(chalk.dim(`Sending notification to ${name}...`))

const mailgun = email[0]
const emailName = service.split('(').pop().slice(0, -1)

const mailgun = email.filter(e => e.name === emailName)[0]
const notification = notifications.filter(n => n.subject === subject)[0]
const to = team.filter(m => m.name === name)[0].email

Expand Down

0 comments on commit e7462e1

Please sign in to comment.