Skip to content

Commit

Permalink
fix(clipboard): try/catch the auth code copying to allow systems like…
Browse files Browse the repository at this point in the history
… docker to work
  • Loading branch information
ctrlc03 committed Oct 24, 2023
1 parent d00ebd1 commit 21f8410
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/phase2cli/src/commands/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,14 @@ export const expirationCountdownForGithubOAuth = (expirationInSeconds: number) =
*/
export const onVerification = async (verification: Verification): Promise<void> => {
// Copy code to clipboard.
clipboard.writeSync(verification.user_code)
clipboard.readSync()
let noClipboard = false
try {
clipboard.writeSync(verification.user_code)
clipboard.readSync()
} catch (error) {
noClipboard = true
}


// Display data.
console.log(
Expand All @@ -75,10 +81,11 @@ export const onVerification = async (verification: Verification): Promise<void>

console.log(theme.colors.magenta(figlet.textSync("Code is Below", { font: "ANSI Shadow" })), "\n")

const message = noClipboard ? `has been copied to your clipboard (${theme.emojis.clipboard})` : ``
console.log(
`${theme.symbols.info} Your auth code: ${theme.text.bold(
verification.user_code
)} has been copied to your clipboard (${theme.emojis.clipboard} ${theme.symbols.success})\n`
)} ${message} ${theme.symbols.success})\n`
)

const spinner = customSpinner(`Redirecting to Github...`, `clock`)
Expand Down

0 comments on commit 21f8410

Please sign in to comment.