fix: retain env-backed ClickClack accounts

This commit is contained in:
Shakker
2026-07-15 13:05:10 +01:00
committed by Shakker
parent 7af8f7dc22
commit 2c7705e363
2 changed files with 10 additions and 2 deletions
+7 -1
View File
@@ -2,7 +2,7 @@
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { describe, expect, it } from "vitest";
import { afterEach, describe, expect, it, vi } from "vitest";
import {
listClickClackAccountIds,
resolveClickClackAccount,
@@ -11,6 +11,10 @@ import {
import type { CoreConfig } from "./types.js";
describe("ClickClack account resolution", () => {
afterEach(() => {
vi.unstubAllEnvs();
});
it("preserves top-level default account when named accounts are configured", () => {
const cfg = {
channels: {
@@ -137,7 +141,9 @@ describe("ClickClack account resolution", () => {
},
} satisfies CoreConfig;
const env = { CLICKCLACK_BOT_TOKEN: " default-env-token " };
vi.stubEnv("CLICKCLACK_BOT_TOKEN", env.CLICKCLACK_BOT_TOKEN);
expect(listClickClackAccountIds(cfg)).toEqual(["default", "work"]);
expect(resolveClickClackAccount({ cfg, env }).token).toBe("default-env-token");
expect(resolveClickClackAccount({ cfg, accountId: "work", env }).token).toBe("");
});
+3 -1
View File
@@ -32,7 +32,9 @@ const {
const channel = cfg.channels?.clickclack;
return Boolean(
channel?.baseUrl?.trim() &&
(hasConfiguredAccountValue(channel.token) || Boolean(channel.tokenFile?.trim())) &&
(hasConfiguredAccountValue(channel.token) ||
Boolean(channel.tokenFile?.trim()) ||
Boolean(process.env.CLICKCLACK_BOT_TOKEN?.trim())) &&
channel.workspace?.trim(),
);
},