mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-13 02:14:32 +00:00
fix(websearch): add shell option for Windows spawnSync compatibility
On Windows, globally installed CLI tools via npm/pnpm are .cmd/.bat batch files, not real .exe executables. Node.js spawnSync() without the shell option cannot execute these files and returns ENOENT error. Changes: - Extract isWindows as a global constant at file top - Add shell: isWindows to all CLI execution spawnSync calls - Remove duplicate isWindows declaration in isCliAvailable() Fixes #378 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
7fbe6b2b54
commit
3c534f48cb
1 file changed
+15
-1
@@ -26,6 +26,18 @@
|
|||||||
|
|
||||||
const { spawnSync } = require('child_process');
|
const { spawnSync } = require('child_process');
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// PLATFORM DETECTION
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Windows platform flag - used for shell option in spawnSync calls.
|
||||||
|
* On Windows, globally installed CLI tools via npm/pnpm are .cmd/.bat files,
|
||||||
|
* which require shell: true to execute properly.
|
||||||
|
* @see https://github.com/kaitranntt/ccs/issues/378
|
||||||
|
*/
|
||||||
|
const isWindows = process.platform === 'win32';
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// CONFIGURATION - Edit these for prompt engineering
|
// CONFIGURATION - Edit these for prompt engineering
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -154,7 +166,6 @@ process.stdin.on('error', () => {
|
|||||||
*/
|
*/
|
||||||
function isCliAvailable(cmd) {
|
function isCliAvailable(cmd) {
|
||||||
try {
|
try {
|
||||||
const isWindows = process.platform === 'win32';
|
|
||||||
const whichCmd = isWindows ? 'where.exe' : 'which';
|
const whichCmd = isWindows ? 'where.exe' : 'which';
|
||||||
|
|
||||||
const result = spawnSync(whichCmd, [cmd], {
|
const result = spawnSync(whichCmd, [cmd], {
|
||||||
@@ -292,6 +303,7 @@ function tryGeminiSearch(query, timeoutSec = DEFAULT_TIMEOUT_SEC) {
|
|||||||
timeout: timeoutMs,
|
timeout: timeoutMs,
|
||||||
maxBuffer: 1024 * 1024 * 2,
|
maxBuffer: 1024 * 1024 * 2,
|
||||||
stdio: ['pipe', 'pipe', 'pipe'],
|
stdio: ['pipe', 'pipe', 'pipe'],
|
||||||
|
shell: isWindows,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -358,6 +370,7 @@ function tryOpenCodeSearch(query, timeoutSec = DEFAULT_TIMEOUT_SEC) {
|
|||||||
timeout: timeoutMs,
|
timeout: timeoutMs,
|
||||||
maxBuffer: 1024 * 1024 * 2,
|
maxBuffer: 1024 * 1024 * 2,
|
||||||
stdio: ['pipe', 'pipe', 'pipe'],
|
stdio: ['pipe', 'pipe', 'pipe'],
|
||||||
|
shell: isWindows,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -417,6 +430,7 @@ function tryGrokSearch(query, timeoutSec = DEFAULT_TIMEOUT_SEC) {
|
|||||||
timeout: timeoutMs,
|
timeout: timeoutMs,
|
||||||
maxBuffer: 1024 * 1024 * 2,
|
maxBuffer: 1024 * 1024 * 2,
|
||||||
stdio: ['pipe', 'pipe', 'pipe'],
|
stdio: ['pipe', 'pipe', 'pipe'],
|
||||||
|
shell: isWindows,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (spawnResult.error) {
|
if (spawnResult.error) {
|
||||||
|
|||||||
Reference in new issue
Block a user