Compare commits

...

2 Commits

Author SHA1 Message Date
Haileyesus
3bbd56e8e9 fix: remove unnecessary child_process imports 2026-04-10 16:50:50 +03:00
Haileyesus
11733918e5 fix: replace child_process with cross-spawn 2026-04-10 16:37:47 +03:00
15 changed files with 19 additions and 27 deletions

View File

@@ -1,12 +1,8 @@
import { spawn } from 'child_process'; import { spawn } from 'cross-spawn';
import crossSpawn from 'cross-spawn';
import { notifyRunFailed, notifyRunStopped } from './services/notification-orchestrator.js'; import { notifyRunFailed, notifyRunStopped } from './services/notification-orchestrator.js';
import { cursorAdapter } from './providers/cursor/adapter.js'; import { cursorAdapter } from './providers/cursor/adapter.js';
import { createNormalizedMessage } from './providers/types.js'; import { createNormalizedMessage } from './providers/types.js';
// Use cross-spawn on Windows for better command execution
const spawnFunction = process.platform === 'win32' ? crossSpawn : spawn;
let activeCursorProcesses = new Map(); // Track active processes by session ID let activeCursorProcesses = new Map(); // Track active processes by session ID
const WORKSPACE_TRUST_PATTERNS = [ const WORKSPACE_TRUST_PATTERNS = [
@@ -122,7 +118,7 @@ async function spawnCursor(command, options = {}, ws) {
console.log('Working directory:', workingDir); console.log('Working directory:', workingDir);
console.log('Session info - Input sessionId:', sessionId, 'Resume:', resume); console.log('Session info - Input sessionId:', sessionId, 'Resume:', resume);
const cursorProcess = spawnFunction('cursor-agent', args, { const cursorProcess = spawn('cursor-agent', args, {
cwd: workingDir, cwd: workingDir,
stdio: ['pipe', 'pipe', 'pipe'], stdio: ['pipe', 'pipe', 'pipe'],
env: { ...process.env } // Inherit all environment variables env: { ...process.env } // Inherit all environment variables

View File

@@ -1,8 +1,4 @@
import { spawn } from 'child_process'; import { spawn } from 'cross-spawn';
import crossSpawn from 'cross-spawn';
// Use cross-spawn on Windows for correct .cmd resolution (same pattern as cursor-cli.js)
const spawnFunction = process.platform === 'win32' ? crossSpawn : spawn;
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';
import path from 'path'; import path from 'path';
import os from 'os'; import os from 'os';
@@ -168,7 +164,7 @@ async function spawnGemini(command, options = {}, ws) {
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const geminiProcess = spawnFunction(spawnCmd, spawnArgs, { const geminiProcess = spawn(spawnCmd, spawnArgs, {
cwd: workingDir, cwd: workingDir,
stdio: ['pipe', 'pipe', 'pipe'], stdio: ['pipe', 'pipe', 'pipe'],
env: { ...process.env } // Inherit all environment variables env: { ...process.env } // Inherit all environment variables

View File

@@ -39,7 +39,7 @@ import os from 'os';
import http from 'http'; import http from 'http';
import cors from 'cors'; import cors from 'cors';
import { promises as fsPromises } from 'fs'; import { promises as fsPromises } from 'fs';
import { spawn } from 'child_process'; import { spawn } from 'cross-spawn';
import pty from 'node-pty'; import pty from 'node-pty';
import fetch from 'node-fetch'; import fetch from 'node-fetch';
import mime from 'mime-types'; import mime from 'mime-types';

View File

@@ -1,5 +1,5 @@
import express from 'express'; import express from 'express';
import { spawn } from 'child_process'; import { spawn } from 'cross-spawn';
import path from 'path'; import path from 'path';
import os from 'os'; import os from 'os';
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';

View File

@@ -1,5 +1,5 @@
import express from 'express'; import express from 'express';
import { spawn } from 'child_process'; import { spawn } from 'cross-spawn';
import fs from 'fs/promises'; import fs from 'fs/promises';
import path from 'path'; import path from 'path';
import os from 'os'; import os from 'os';

View File

@@ -1,5 +1,5 @@
import express from 'express'; import express from 'express';
import { spawn } from 'child_process'; import { spawn } from 'cross-spawn';
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';
import path from 'path'; import path from 'path';
import os from 'os'; import os from 'os';

View File

@@ -2,7 +2,7 @@ import express from 'express';
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';
import path from 'path'; import path from 'path';
import os from 'os'; import os from 'os';
import { spawn } from 'child_process'; import { spawn } from 'cross-spawn';
import sqlite3 from 'sqlite3'; import sqlite3 from 'sqlite3';
import { open } from 'sqlite'; import { open } from 'sqlite';
import crypto from 'crypto'; import crypto from 'crypto';
@@ -795,4 +795,4 @@ router.get('/sessions/:sessionId', async (req, res) => {
} }
}); });
export default router; export default router;

View File

@@ -1,5 +1,5 @@
import express from 'express'; import express from 'express';
import { spawn } from 'child_process'; import { spawn } from 'cross-spawn';
import path from 'path'; import path from 'path';
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';
import { extractProjectDirectory } from '../projects.js'; import { extractProjectDirectory } from '../projects.js';

View File

@@ -4,7 +4,7 @@ import path from 'path';
import os from 'os'; import os from 'os';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
import { dirname } from 'path'; import { dirname } from 'path';
import { spawn } from 'child_process'; import { spawn } from 'cross-spawn';
const router = express.Router(); const router = express.Router();
const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);
@@ -549,4 +549,4 @@ function parseClaudeGetOutput(output) {
} }
} }
export default router; export default router;

View File

@@ -1,7 +1,7 @@
import express from 'express'; import express from 'express';
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';
import path from 'path'; import path from 'path';
import { spawn } from 'child_process'; import { spawn } from 'cross-spawn';
import os from 'os'; import os from 'os';
import { addProjectManually } from '../projects.js'; import { addProjectManually } from '../projects.js';

View File

@@ -12,7 +12,7 @@ import express from 'express';
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import { promises as fsPromises } from 'fs'; import { promises as fsPromises } from 'fs';
import { spawn } from 'child_process'; import { spawn } from 'cross-spawn';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
import { dirname } from 'path'; import { dirname } from 'path';
import os from 'os'; import os from 'os';

View File

@@ -2,7 +2,7 @@ import express from 'express';
import { userDb } from '../database/db.js'; import { userDb } from '../database/db.js';
import { authenticateToken } from '../middleware/auth.js'; import { authenticateToken } from '../middleware/auth.js';
import { getSystemGitConfig } from '../utils/gitConfig.js'; import { getSystemGitConfig } from '../utils/gitConfig.js';
import { spawn } from 'child_process'; import { spawn } from 'cross-spawn';
const router = express.Router(); const router = express.Router();

View File

@@ -1,4 +1,4 @@
import { spawn } from 'child_process'; import { spawn } from 'cross-spawn';
function spawnAsync(command, args) { function spawnAsync(command, args) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {

View File

@@ -1,7 +1,7 @@
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import os from 'os'; import os from 'os';
import { spawn } from 'child_process'; import { spawn } from 'cross-spawn';
const PLUGINS_DIR = path.join(os.homedir(), '.claude-code-ui', 'plugins'); const PLUGINS_DIR = path.join(os.homedir(), '.claude-code-ui', 'plugins');
const PLUGINS_CONFIG_PATH = path.join(os.homedir(), '.claude-code-ui', 'plugins.json'); const PLUGINS_CONFIG_PATH = path.join(os.homedir(), '.claude-code-ui', 'plugins.json');

View File

@@ -1,4 +1,4 @@
import { spawn } from 'child_process'; import { spawn } from 'cross-spawn';
import path from 'path'; import path from 'path';
import { scanPlugins, getPluginsConfig, getPluginDir } from './plugin-loader.js'; import { scanPlugins, getPluginsConfig, getPluginDir } from './plugin-loader.js';