44 * Requires Claude Code (claude) CLI to be installed.
55 */
66
7- import { spawn } from '@socketsecurity/lib/spawn'
87import crypto from 'node:crypto'
98import {
109 existsSync ,
@@ -20,6 +19,7 @@ import { deleteAsync as del } from 'del'
2019import colors from 'yoctocolors-cjs'
2120
2221import { parseArgs } from '@socketsecurity/lib/argv/parse'
22+ import { spawn } from '@socketsecurity/lib/spawn'
2323
2424const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
2525const rootPath = path . join ( __dirname , '..' )
@@ -892,13 +892,15 @@ function displayAnalysis(analysis) {
892892async function runCommand ( command , args = [ ] , options = { } ) {
893893 const opts = { __proto__ : null , ...options }
894894 return new Promise ( ( resolve , reject ) => {
895- const child = spawn ( command , args , {
895+ const spawnPromise = spawn ( command , args , {
896896 stdio : 'inherit' ,
897897 cwd : rootPath ,
898898 ...( WIN32 && { shell : true } ) ,
899899 ...opts ,
900900 } )
901901
902+ const child = spawnPromise . process
903+
902904 child . on ( 'exit' , code => {
903905 resolve ( code || 0 )
904906 } )
@@ -917,12 +919,14 @@ async function runCommandWithOutput(command, args = [], options = {}) {
917919 let stdout = ''
918920 let stderr = ''
919921
920- const child = spawn ( command , args , {
922+ const spawnPromise = spawn ( command , args , {
921923 cwd : rootPath ,
922924 ...( WIN32 && { shell : true } ) ,
923925 ...spawnOpts ,
924926 } )
925927
928+ const child = spawnPromise . process
929+
926930 // Write input to stdin if provided.
927931 if ( input && child . stdin ) {
928932 child . stdin . write ( input )
@@ -1022,12 +1026,14 @@ async function runClaude(claudeCmd, prompt, options = {}) {
10221026 if ( opts . interactive !== false ) {
10231027 // Interactive mode - spawn with inherited stdio and pipe prompt
10241028 result = await new Promise ( ( resolve , _reject ) => {
1025- const child = spawn ( claudeCmd , args , {
1029+ const spawnPromise = spawn ( claudeCmd , args , {
10261030 stdio : [ 'pipe' , 'inherit' , 'inherit' ] ,
10271031 cwd : opts . cwd || rootPath ,
10281032 ...( WIN32 && { shell : true } ) ,
10291033 } )
10301034
1035+ const child = spawnPromise . process
1036+
10311037 // Set up timeout for interactive mode
10321038 const timeoutId = setTimeout ( ( ) => {
10331039 timedOut = true
@@ -4716,12 +4722,14 @@ Fix all issues by making necessary file changes. Be direct, don't ask questions.
47164722 }
47174723
47184724 const exitCode = await new Promise ( ( resolve , _reject ) => {
4719- const child = spawn ( scriptCmd , [ ] , {
4725+ const spawnPromise = spawn ( scriptCmd , [ ] , {
47204726 stdio : 'inherit' ,
47214727 cwd : rootPath ,
47224728 shell : true ,
47234729 } )
47244730
4731+ const child = spawnPromise . process
4732+
47254733 // Handle Ctrl+C gracefully
47264734 const sigintHandler = ( ) => {
47274735 child . kill ( 'SIGINT' )
@@ -5036,12 +5044,14 @@ Fix the issue by making necessary file changes. Be direct, don't ask questions.`
50365044 }
50375045
50385046 const exitCode = await new Promise ( ( resolve , _reject ) => {
5039- const child = spawn ( scriptCmd , [ ] , {
5047+ const spawnPromise = spawn ( scriptCmd , [ ] , {
50405048 stdio : 'inherit' ,
50415049 cwd : rootPath ,
50425050 shell : true ,
50435051 } )
50445052
5053+ const child = spawnPromise . process
5054+
50455055 // Handle Ctrl+C gracefully
50465056 const sigintHandler = ( ) => {
50475057 child . kill ( 'SIGINT' )
0 commit comments