Skip to content

Commit cfbef3a

Browse files
committed
📦 NEW: try & catch
1 parent b5107d2 commit cfbef3a

7 files changed

Lines changed: 32 additions & 37 deletions

File tree

‎utils/auth.js‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎utils/authentication.js‎

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
const fs = require("fs");
22
const io = require("console-read-write");
33
const { green, red, yellow } = require("chalk");
4-
const auth = require("./auth.js");
4+
const pwd = process.cwd();
55

6-
module.exports = async () => {
7-
if (auth.Authorization === "") {
6+
try {
7+
const newAuth = require(`${pwd}/auth.js`);
8+
} catch (error) {
9+
module.exports = async () => {
810
io.write(
911
red(
10-
"\n> This CLI will work best if you enter your GitHub Access Token & Username. THIS IS ONE TIME THING.\n"
12+
"\n> This CLI will work best if you enter your GitHub Access Token. THIS IS ONE TIME THING.\n"
1113
)
1214
);
1315
io.write(
@@ -19,22 +21,10 @@ module.exports = async () => {
1921
io.write(yellow("Token: "));
2022
const token = await io.read();
2123

22-
io.write(yellow("GitHub Username: "));
23-
const username = await io.read();
24-
2524
const userToken = `module.exports = {
26-
Authorization: "Token ${token}",
27-
}`;
28-
29-
const userData = `module.exports = {
30-
username: "${username}",
31-
}`;
25+
Authorization: "Token ${token}",
26+
}`;
3227

33-
fs.writeFile(`./auth.js`, userToken, (err) => {
34-
console.log(err);
35-
});
36-
fs.writeFile(`./user.js`, userData, (err) => {
37-
console.log(err);
38-
});
39-
}
40-
};
28+
fs.writeFile(`./auth.js`, userToken, (err) => {});
29+
};
30+
}

‎utils/createIssue.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
* Twitter: https://twitter.com/msaaddev
66
*/
77

8+
const pwd = process.cwd();
89
const io = require("console-read-write");
910
const { cyan, green } = require("chalk");
1011
const axios = require("axios");
1112
const box = require("./box.js");
12-
const headers = require("./auth");
13+
let headers;
14+
try {
15+
headers = require(`${pwd}/auth.js`);
16+
} catch (error) {}
1317

1418
module.exports = async () => {
1519
io.write("------------------------------------------");

‎utils/createRepo.js‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,20 @@
55
* Twitter: https://twitter.com/msaaddev
66
*/
77

8+
const pwd = process.cwd();
89
const io = require("console-read-write");
910
const { cyan, green } = require("chalk");
1011
const axios = require("axios");
1112
const box = require("./box.js");
12-
let { username } = require("./user.js");
13-
const headers = require("./auth.js");
13+
let headers;
14+
try {
15+
headers = require(`${pwd}/auth.js`);
16+
} catch (error) {}
1417

1518
module.exports = async () => {
1619
io.write("------------------------------------------");
1720
// getting data from terminal
18-
if (username === "") {
19-
io.write(cyan("> Enter GitHub Username"));
20-
username = await io.read();
21-
io.write("");
22-
}
21+
2322
io.write(cyan("> Enter Repo Title"));
2423
const title = await io.read();
2524
io.write("");

‎utils/getEmail.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
* Twitter: https://twitter.com/msaaddev
66
*/
77

8+
const pwd = process.cwd();
89
const io = require("console-read-write");
910
const { cyan } = require("chalk");
1011
const axios = require("axios");
1112
const box = require("./box.js");
12-
const headers = require("./auth.js");
13+
let headers;
14+
try {
15+
headers = require(`${pwd}/auth.js`);
16+
} catch (error) {}
1317

1418
module.exports = async () => {
1519
io.write("------------------------------------------");

‎utils/getStargazer.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
* Twitter: https://twitter.com/msaaddev
66
*/
77

8+
const pwd = process.cwd();
89
const io = require("console-read-write");
910
const { cyan } = require("chalk");
1011
const axios = require("axios");
1112
const box = require("./box.js");
12-
const headers = require("./auth.js");
13+
let headers;
14+
try {
15+
headers = require(`${pwd}/auth.js`);
16+
} catch (error) {}
1317

1418
module.exports = async () => {
1519
io.write("------------------------------------------");

‎utils/user.js‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)