Skip to content

Commit 920b38c

Browse files
committed
Cleanup getDefaultOrgSlug
1 parent b499bd6 commit 920b38c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/commands/ci/fetch-default-org-slug.mts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@ export async function getDefaultOrgSlug(): Promise<CResult<string>> {
3030
return result
3131
}
3232

33-
const orgs = result.data.organizations
34-
const keys = Object.keys(orgs)
33+
const { organizations } = result.data
34+
const keys = Object.keys(organizations)
3535

36-
if (!keys[0]) {
36+
if (!keys.length) {
3737
return {
3838
ok: false,
3939
message: 'Failed to establish identity',
4040
data: `API did not return any organization associated with the current API token. Unable to continue.`,
4141
}
4242
}
4343

44-
const slug = (keys[0] in orgs && orgs?.[keys[0]]?.name) ?? undefined
44+
const slug = (organizations as any)[keys[0]!]?.name ?? undefined
4545

4646
if (!slug) {
4747
return {

0 commit comments

Comments
 (0)