File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -72,11 +72,22 @@ const cloneRepository = async () => {
7272 */
7373
7474const createRepository = async ( ) => {
75- const API_URL = 'https://api.github.com/user/repos' ;
76- const options = `--silent --output /dev/null -u ${ GHUserName } ${ API_URL } -d '{"name":"teachcode-solutions"}'` ;
75+ const { userToken } = await inquirer . prompt ( {
76+ name : 'userToken' ,
77+ message : 'GitHub user token:-' ,
78+ type : 'password' ,
79+ validate,
80+ } ) ;
81+ const API_URL = `https://api.github.com/user/repos?access_token=${ userToken } ` ;
7782
7883 // Create a new repository.
79- await execa . shell ( `curl ${ options } ` , { stdio : 'inherit' } ) ;
84+ try {
85+ await axios . post ( API_URL , { name : 'teachcode-solutions' } ) ;
86+ } catch ( err ) {
87+ console . log ( chalk . red . bold ( 'Error: Invalid credentials' ) ) ;
88+ console . log ( err ) ;
89+ await createRepository ( ) ;
90+ }
8091
8192 // Ensure repository creation.
8293 if ( await checkIfRepositoryExists ( ) ) {
@@ -85,7 +96,6 @@ const createRepository = async () => {
8596 await createRepository ( ) ;
8697 }
8798} ;
88-
8999/**
90100 * Configure local repository
91101 *
You can’t perform that action at this time.
0 commit comments