11const fs = require ( "fs" ) ;
22const io = require ( "console-read-write" ) ;
33const { 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+ }
0 commit comments