-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}; |