fix: conditionally enable shell on Windows for npx spawn calls

This commit is contained in:
2026-06-15 12:20:12 +08:00
parent 78208cd4b1
commit c2a9fcdb2e

View File

@@ -36,7 +36,7 @@ function apiSavePlugin() {
server.middlewares.use('/api/ai/sessions', (req: any, res: any) => {
if (req.method !== 'GET') { res.writeHead(405); res.end(); return }
try {
const child = spawn('npx', ['opencode', 'session', 'list', '--format', 'json'], { timeout: 5000, stdio: ['ignore', 'pipe', 'pipe'] })
const child = spawn('npx', ['opencode', 'session', 'list', '--format', 'json'], { timeout: 5000, stdio: ['ignore', 'pipe', 'pipe'], shell: process.platform === 'win32' })
let stdout = ''
let responded = false
child.stdout.on('data', (d: Buffer) => stdout += d.toString())
@@ -89,6 +89,7 @@ function apiSavePlugin() {
env: { ...process.env, DEEPSEEK_API_KEY: apiKey || process.env.DEEPSEEK_API_KEY || '' },
timeout: 60000,
stdio: ['ignore', 'pipe', 'pipe'],
shell: process.platform === 'win32',
})
let stdout = ''