Skip to content

Commit cbe1e4d

Browse files
committed
👌IMPROVE: name change
1 parent 9bf28c8 commit cbe1e4d

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

utils/getEmail.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
*
3+
* Author: Muhammad Saad
4+
* GitHub: msaaddev
5+
* Twitter: https://twitter.com/msaaddev
6+
*/
7+
8+
const io = require("console-read-write");
9+
const { cyan } = require("chalk");
10+
const box = require("./box");
11+
const axios = require("axios");
12+
13+
module.exports = async () => {
14+
console.log("------------------------------------------");
15+
// getting data from terminal
16+
io.write(cyan("> Enter GitHub Username"));
17+
const URL = await io.read();
18+
await axios
19+
.get(`https://api.github.com/users/${URL}/events/public`)
20+
.then((res) => {
21+
for (let i = 0; i < res.data.length; i++) {
22+
if (res.data[i].type === "PushEvent") {
23+
const name = "✉️ Email";
24+
box(name, res.data[i].payload.commits[0].author.email);
25+
break;
26+
}
27+
if (i === res.data.length - 1) {
28+
const name = "⚠️ WARNING";
29+
const msg = "No Email Found!!";
30+
box(name, msg);
31+
}
32+
}
33+
})
34+
.catch((err) => {
35+
const name = "⚠️ WARNING";
36+
const msg = "Cannot Access Email!!";
37+
box(name, msg);
38+
});
39+
};

0 commit comments

Comments
 (0)