Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/commands/auth/auth-login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ export const loginCommand = new Command()
.option("-k, --key <key:string>", "API key (prompted if not provided)")
.action(async (options) => {
try {
let apiKey = options.key
let apiKey = options.key?.trim()

if (!apiKey) {
apiKey = await Secret.prompt({
apiKey = (await Secret.prompt({
message: "Enter your Linear API key",
hint: "Create one at https://linear.app/settings/account/security",
})
}))?.trim()
}

if (!apiKey) {
Expand All @@ -50,6 +50,9 @@ export const loginCommand = new Command()
})
}

// Strip stray characters that some terminals (e.g. Windows) inject around pasted text
apiKey = apiKey.replace(/^[^a-zA-Z0-9_]+|[^a-zA-Z0-9_]+$/g, "")

// Validate the API key by querying the API
const client = createGraphQLClient(apiKey)

Expand Down