-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.js
45 lines (42 loc) · 1.53 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
*
* Author: Muhammad Saad
* GitHub: msaaddev
* Twitter: https://twitter.com/msaaddev
*/
const io = require("console-read-write");
const { cyan, red, green } = require("chalk");
const axios = require("axios");
const emailFetchAutomation = async () => {
console.log("------------------------------------------");
// getting data from terminal
io.write(cyan("> Enter GitHub username"));
const URL = await io.read();
await axios
.get(`https://api.github.com/users/${URL}/events/public`)
.then((res) => {
for (let i = 0; i < res.data.length; i++) {
if (res.data[i].type === "PushEvent") {
console.log(green(" -------------------------------------------"));
console.log(green(" | |"));
console.log(
green(" ✉️ Email: ") +
res.data[i].payload.commits[0].author.email
);
console.log(green(" | |"));
console.log(green(" -------------------------------------------"));
break;
}
}
})
.catch((err) => {
console.log(red(" ------------------------------------------"));
console.log(red(" | |"));
console.log(
red(" | ⚠️ WARNING: ") + "Cannot Access Email!!" + red(" |")
);
console.log(red(" | |"));
console.log(red(" ------------------------------------------"));
});
};
emailFetchAutomation();