-
Notifications
You must be signed in to change notification settings - Fork 21
refactor(commands): extract getRootOpts() helper #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,9 +1,18 @@ | ||||||||||
| import type { Command } from "commander"; | ||||||||||
| import { GraphQLClient } from "../client/graphql-client.js"; | ||||||||||
| import { LinearSdkClient } from "../client/linear-client.js"; | ||||||||||
| import { type CommandOptions, getApiToken } from "./auth.js"; | ||||||||||
|
|
||||||||||
| export type { CommandOptions }; | ||||||||||
|
|
||||||||||
| export function getRootOpts(command: Command): CommandOptions { | ||||||||||
| let current: Command | null = command; | ||||||||||
| while (current?.parent) { | ||||||||||
|
Comment on lines
+9
to
+10
|
||||||||||
| let current: Command | null = command; | |
| while (current?.parent) { | |
| let current = command; | |
| while (current.parent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
currentdoesn't need to beCommand | null— it starts ascommand(non-null) and the loop only assignscurrent.parentwhen it's truthy. You can simplify to:This drops the optional chaining and keeps the type as
Commandthroughout — no null narrowing needed, andcurrent.opts()is unambiguously safe.