mirror of
https://github.com/tiennm99/ccs.git
synced 2026-09-02 22:17:14 +00:00
fix(doctor): resolve windows claude cli detection failure
Windows .cmd/.bat wrapper scripts require shell: true in spawn options. Uses same pattern as other files (ccs.ts, cliproxy-executor.ts, shell-executor.ts): - getClaudeCliInfo() returns needsShell flag - Concatenate command string when shell needed to avoid DEP0190 warning Closes #41
This commit is contained in:
@@ -6,7 +6,8 @@ import * as fs from 'fs';
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import { spawn } from 'child_process';
|
import { spawn } from 'child_process';
|
||||||
import { detectClaudeCli } from '../utils/claude-detector';
|
import { getClaudeCliInfo } from '../utils/claude-detector';
|
||||||
|
import { escapeShellArg } from '../utils/shell-executor';
|
||||||
import { initUI, header, box, table, color, ok, fail, warn, info } from '../utils/ui';
|
import { initUI, header, box, table, color, ok, fail, warn, info } from '../utils/ui';
|
||||||
import packageJson from '../../package.json';
|
import packageJson from '../../package.json';
|
||||||
import {
|
import {
|
||||||
@@ -180,9 +181,9 @@ class Doctor {
|
|||||||
private async checkClaudeCli(): Promise<void> {
|
private async checkClaudeCli(): Promise<void> {
|
||||||
const spinner = ora('Checking Claude CLI').start();
|
const spinner = ora('Checking Claude CLI').start();
|
||||||
|
|
||||||
const claudeCli = detectClaudeCli();
|
const cliInfo = getClaudeCliInfo();
|
||||||
|
|
||||||
if (!claudeCli) {
|
if (!cliInfo) {
|
||||||
spinner.fail();
|
spinner.fail();
|
||||||
console.log(` ${fail('Claude CLI'.padEnd(22))} Not found in PATH`);
|
console.log(` ${fail('Claude CLI'.padEnd(22))} Not found in PATH`);
|
||||||
this.results.addCheck(
|
this.results.addCheck(
|
||||||
@@ -195,13 +196,23 @@ class Doctor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { path: claudeCli, needsShell } = cliInfo;
|
||||||
|
|
||||||
// Try to execute claude --version
|
// Try to execute claude --version
|
||||||
try {
|
try {
|
||||||
const result = await new Promise<string>((resolve, reject) => {
|
const result = await new Promise<string>((resolve, reject) => {
|
||||||
const child = spawn(claudeCli, ['--version'], {
|
// When shell is needed (Windows .cmd/.bat files), concatenate into string
|
||||||
stdio: 'pipe',
|
// to avoid DEP0190 warning about passing args with shell: true
|
||||||
timeout: 5000,
|
const child = needsShell
|
||||||
});
|
? spawn([claudeCli, '--version'].map(escapeShellArg).join(' '), {
|
||||||
|
stdio: 'pipe',
|
||||||
|
timeout: 5000,
|
||||||
|
shell: true,
|
||||||
|
})
|
||||||
|
: spawn(claudeCli, ['--version'], {
|
||||||
|
stdio: 'pipe',
|
||||||
|
timeout: 5000,
|
||||||
|
});
|
||||||
|
|
||||||
let output = '';
|
let output = '';
|
||||||
child.stdout?.on('data', (data: Buffer) => (output += data));
|
child.stdout?.on('data', (data: Buffer) => (output += data));
|
||||||
|
|||||||
Reference in New Issue
Block a user