Skip to content

Commit

Permalink
👌IMPROVE: name change
Browse files Browse the repository at this point in the history
  • Loading branch information
msaaddev committed Apr 7, 2020
1 parent 9bf28c8 commit cbe1e4d
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions utils/getEmail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
*
* Author: Muhammad Saad
* GitHub: msaaddev
* Twitter: https://twitter.com/msaaddev
*/

const io = require("console-read-write");
const { cyan } = require("chalk");
const box = require("./box");
const axios = require("axios");

module.exports = 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") {
const name = "✉️ Email";
box(name, res.data[i].payload.commits[0].author.email);
break;
}
if (i === res.data.length - 1) {
const name = "⚠️ WARNING";
const msg = "No Email Found!!";
box(name, msg);
}
}
})
.catch((err) => {
const name = "⚠️ WARNING";
const msg = "Cannot Access Email!!";
box(name, msg);
});
};

0 comments on commit cbe1e4d

Please sign in to comment.