UNPKG

ccgo

Version:

Simple Claude Code launcher with config management and environment variable injection

67 lines 2.1 kB
"use strict"; /** * 安装检查工具 * 检查 Claude Code 是否已安装 */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getClaudeCommand = getClaudeCommand; exports.checkClaudeInstallation = checkClaudeInstallation; exports.getClaudeVersion = getClaudeVersion; const child_process_1 = require("child_process"); const chalk_1 = __importDefault(require("chalk")); /** * 获取 Claude 命令名称(跨平台) * @returns Claude 命令名称 */ function getClaudeCommand() { const isWindows = process.platform === 'win32'; return isWindows ? 'claude.cmd' : 'claude'; } /** * 检查 Claude Code 是否已安装 * @returns 是否已安装 */ function checkClaudeInstallation() { try { const isWindows = process.platform === 'win32'; const checkCommand = isWindows ? 'where claude' : 'which claude'; (0, child_process_1.execSync)(checkCommand, { stdio: 'pipe', encoding: 'utf8' }); return true; } catch { console.log(''); console.log(chalk_1.default.red('✗ 未找到 Claude Code')); console.log(''); console.log(chalk_1.default.white('请先安装 Claude Code:')); console.log(chalk_1.default.cyan(' npm install -g @anthropic-ai/claude-code')); console.log(''); console.log(chalk_1.default.gray('或访问官方文档:')); console.log(chalk_1.default.gray(' https://docs.claude.com/code')); console.log(''); return false; } } /** * 获取 Claude Code 版本 * @returns 版本号或 undefined */ function getClaudeVersion() { try { const claudeCmd = getClaudeCommand(); const output = (0, child_process_1.execSync)(`${claudeCmd} --version`, { stdio: 'pipe', encoding: 'utf8' }); return output.trim(); } catch { return undefined; } } //# sourceMappingURL=installer.js.map