Skip to content

Commit

Permalink
build: 3.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosCarmona committed Feb 27, 2021
1 parent e74186f commit dffc4f8
Show file tree
Hide file tree
Showing 7 changed files with 1,516 additions and 150 deletions.
12 changes: 11 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
"indent": ["error", 2, { "SwitchCase": 1 }],
"default-case": "error",
"linebreak-style": ["error", "unix"],
"semi": ["error", "always"]
"semi": ["error", "always"],
"no-console": "error",
"no-undef": "error",
"no-var": "error",
"no-caller": "error",
"no-throw-literal": "error",
"no-unneeded-ternary": "error",
"prefer-const": "error",
"comma-spacing": ["error", { "before": false, "after": true }],
"comma-style": ["error", "last"],
"handle-callback-err": ["error", "^(err|error)$"]
}
}
8 changes: 2 additions & 6 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
node_modules
.all-contributorsrc
.eslintignore
.gitignore
.prettierignore
.DS_Store
.npmignore
LICENSE
*.png
*.txt
TODO
.npmignore
docs/functions.md
*.md
test.log
.DS_Store
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
<p align="center">A new way for processes managing</p>
</p>

[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Dependency Status][david-badge]][david-badge-url]
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Dependency Status][david-badge]][david-badge-url]
<a href="#badge">
<img alt="code style: prettier" src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg">
<img alt="code style: prettier" src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg">
</a>


# Mail notifier for [Runnerty]:

Email notification module with [ejs] template support.

### Installation:

Through NPM

```bash
Expand All @@ -36,7 +37,9 @@ rty add @runnerty/notifier-mail
```

### Configuration sample:

Add in [config.json]:

```json
{
"notifiers": [
Expand All @@ -54,6 +57,7 @@ Add in [config.json]:
]
}
```

```json
{
"notifiers": [
Expand Down Expand Up @@ -90,7 +94,9 @@ Add in [config.json]:
```

### Plan sample:

Add in [plan.json]:

```json
{
"notifications": {
Expand All @@ -105,7 +111,7 @@ Add in [plan.json]:
}
```

[Runnerty]: http://www.runnerty.io
[runnerty]: http://www.runnerty.io
[downloads-image]: https://img.shields.io/npm/dm/@runnerty/notifier-mail.svg
[npm-url]: https://www.npmjs.com/package/@runnerty/notifier-mail
[npm-image]: https://img.shields.io/npm/v/@runnerty/notifier-mail.svg
Expand All @@ -114,4 +120,4 @@ Add in [plan.json]:
[config.json]: http://docs.runnerty.io/config/
[plan.json]: http://docs.runnerty.io/plan/
[ejs]: https://ejs.co
[runnerty-cli]: https://www.npmjs.com/package/runnerty-cli
[runnerty-cli]: https://www.npmjs.com/package/runnerty-cli
20 changes: 10 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ class mailNotifier extends Notifier {
}

send(notification) {
let endOptions = {};
const endOptions = {};
notification.to = notification.to ? notification.to.toString() : '';
notification.cc = notification.cc ? notification.cc.toString() : '';
notification.bcc = notification.bcc ? notification.bcc.toString() : '';

let transport = nodemailer.createTransport(notification.transport);
let filesReads = [];
const transport = nodemailer.createTransport(notification.transport);
const filesReads = [];

let templateDir = path.resolve(notification.templateDir, notification.template);
let htmlTemplate = path.resolve(templateDir, 'html.html');
let txtTemplate = path.resolve(templateDir, 'text.txt');
const templateDir = path.resolve(notification.templateDir, notification.template);
const htmlTemplate = path.resolve(templateDir, 'html.html');
const txtTemplate = path.resolve(templateDir, 'text.txt');

filesReads.push(this.readFilePromise('html', htmlTemplate));
filesReads.push(this.readFilePromise('text', txtTemplate));
Expand All @@ -38,13 +38,13 @@ class mailNotifier extends Notifier {
[html_data, text_data] = [res[1].html.toString(), res[0].text.toString()];
}

let textData = [];
const textData = [];
textData.push(interpreter(html_data, notification));
textData.push(interpreter(text_data, notification));

Promise.all(textData).then(res => {
let [html, text] = res;
let mailOptions = {
const [html, text] = res;
const mailOptions = {
from: notification.from,
to: notification.to,
cc: notification.cc,
Expand Down Expand Up @@ -81,7 +81,7 @@ class mailNotifier extends Notifier {
readFilePromise(type, file) {
return new Promise((resolve, reject) => {
fs.readFile(file, (err, data) => {
let res = {};
const res = {};
if (err) {
res[type] = err;
reject(res);
Expand Down
Loading

0 comments on commit dffc4f8

Please sign in to comment.