Skip to content
Open
Show file tree
Hide file tree
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
11 changes: 9 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@
*/

import { resolve } from 'path';
import { existsSync } from 'node:fs';
import { homedir } from 'node:os';
import { config as dotenvConfig } from 'dotenv';
import { createApp } from './app.js';
import { getConfig } from './utils/config.js';
import { checkClaudeAvailable } from './claude/index.js';
import { install as startupInstall, uninstall as startupUninstall, isPlatformSupported, getPlatformName } from './startup/index.js';

// 加载环境变量
dotenvConfig({ path: resolve(process.cwd(), '.env') });
// 加载环境变量:优先当前目录,兜底 ~/.claude-client/.env
const localEnvPath = resolve(process.cwd(), '.env');
const globalEnvPath = resolve(homedir(), '.claude-client', '.env');
if (existsSync(localEnvPath)) {
dotenvConfig({ path: localEnvPath });
}
dotenvConfig({ path: globalEnvPath });

const args = process.argv.slice(2);
const command = args[0];
Expand Down
11 changes: 9 additions & 2 deletions src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@

import { config as dotenvConfig } from 'dotenv';
import { resolve } from 'path';
import { existsSync } from 'node:fs';
import { homedir } from 'node:os';
import type { AppConfig, FeishuDomain, ClaudePermissionMode } from '../types/index.js';

// 加载环境变量
dotenvConfig({ path: resolve(process.cwd(), '.env') });
// 加载环境变量:优先当前目录,兜底 ~/.claude-client/.env
const localEnvPath = resolve(process.cwd(), '.env');
const globalEnvPath = resolve(homedir(), '.claude-client', '.env');
if (existsSync(localEnvPath)) {
dotenvConfig({ path: localEnvPath });
}
dotenvConfig({ path: globalEnvPath });

function getEnvString(key: string, defaultValue?: string): string {
const value = process.env[key];
Expand Down