@brimveyn/aimux 1.22.9 → 1.22.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/git/gh-auth.ts +11 -3
package/package.json
CHANGED
package/src/git/gh-auth.ts
CHANGED
|
@@ -34,11 +34,19 @@ export async function listGhAccounts(): Promise<GhAccount[]> {
|
|
|
34
34
|
return parseGhAuthStatus(`${result.stdout}\n${result.stderr}`)
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Where a "switch account" button goes next: the following account, cycling.
|
|
39
|
+
* The order has to come from the names, not from `gh auth status`, which lists
|
|
40
|
+
* the active account first — cycling that puts you back on the account you just
|
|
41
|
+
* left, so a third account is never reachable.
|
|
42
|
+
*/
|
|
38
43
|
export function nextGhAccount(accounts: readonly GhAccount[]): GhAccount | null {
|
|
39
44
|
if (accounts.length < 2) return null
|
|
40
|
-
const
|
|
41
|
-
|
|
45
|
+
const sorted = [...accounts].sort(
|
|
46
|
+
(a, b) => a.host.localeCompare(b.host) || a.user.localeCompare(b.user)
|
|
47
|
+
)
|
|
48
|
+
const index = sorted.findIndex((account) => account.active)
|
|
49
|
+
return sorted[(index + 1) % sorted.length] ?? null
|
|
42
50
|
}
|
|
43
51
|
|
|
44
52
|
/** Returns an error message, or null when the switch landed. */
|