File tree Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Original file line number Diff line number Diff line change @@ -102,15 +102,14 @@ const getPersonalAccessToken = async () => {
102102 */
103103const authWithToken = async ( ) => {
104104 const { token } = await getPersonalAccessToken ( )
105- if ( token ) {
106- const octokit = new Octokit ( {
107- auth : `token ${ token } ` ,
108- } )
109- const { login : user } = await octokit . users . getAuthenticated ( )
110- return { token, user, provider : 'github' }
105+ if ( ! token ) {
106+ throw new Error ( 'GitHub authentication failed' )
111107 }
112- const error = new Error ( 'GitHub authentication failed' )
113- throw error
108+
109+ const octokit = new Octokit ( { auth : `token ${ token } ` } )
110+ const { login : user } = await octokit . users . getAuthenticated ( )
111+
112+ return { token, user, provider : 'github' }
114113}
115114
116115/**
@@ -121,11 +120,8 @@ const getGitHubToken = async () => {
121120 log ( '' )
122121
123122 const withNetlify = await promptForAuthMethod ( )
124- if ( withNetlify ) {
125- return await authWithNetlify ( )
126- }
127123
128- return await authWithToken ( )
124+ return withNetlify ? await authWithNetlify ( ) : await authWithToken ( )
129125}
130126
131127module . exports = { getGitHubToken, authWithNetlify }
You can’t perform that action at this time.
0 commit comments