Skip to content

Commit bf85e08

Browse files
committed
🐛 FIX: edge case
1 parent 218fdf9 commit bf85e08

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,20 @@ const emailFetchAutomation = async () => {
2121
for (let i = 0; i < res.data.length; i++) {
2222
if (res.data[i].type === "PushEvent") {
2323
const name = "✉️ Email";
24-
box(green, name, res.data[i].payload.commits[0].author.email);
24+
box(name, res.data[i].payload.commits[0].author.email);
2525
break;
2626
}
27+
if (i === res.data.length - 1) {
28+
const name = "⚠️ WARNING";
29+
const msg = "No Email Found!!";
30+
box(name, msg);
31+
}
2732
}
2833
})
2934
.catch((err) => {
3035
const name = "⚠️ WARNING";
3136
const msg = "Cannot Access Email!!";
32-
box(red, name, msg);
37+
box(name, msg);
3338
});
3439
};
3540

utils/box.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
const chalk = require("chalk");
22

3-
module.exports = (color, name, data) => {
3+
module.exports = (name, data) => {
44
if (name === "✉️ Email") {
55
console.log(chalk.green(" -------------------------------------------"));
66
console.log(chalk.green(" | |"));
77
console.log(chalk.green(` ${name}: `) + data);
88
console.log(chalk.green(" | |"));
99
console.log(chalk.green(" -------------------------------------------"));
10+
} else if (data === "No Email Found!!") {
11+
console.log(chalk.red(" -------------------------------------------"));
12+
console.log(chalk.red(" | |"));
13+
console.log(chalk.red(` | ${name}: `) + data + chalk.red(" |"));
14+
console.log(chalk.red(" | |"));
15+
console.log(chalk.red(" -------------------------------------------"));
1016
} else {
1117
console.log(chalk.red(" -------------------------------------------"));
1218
console.log(chalk.red(" | |"));

0 commit comments

Comments
 (0)