@@ -11,13 +11,16 @@ module Buffer = {
1111 @send external toString : t => string = "toString"
1212}
1313
14+ type processEnvOptions = {stdio ?: string }
1415type spawnSyncResult = {
1516 stdout : Buffer .t ,
1617 stderr : Buffer .t ,
1718 status : Js .Null .t <int >,
1819}
20+
1921@module ("child_process" )
20- external spawnSync : (string , array <string >) => spawnSyncResult = "spawnSync"
22+ external spawnSync : (string , array <string >, option <processEnvOptions >) => spawnSyncResult =
23+ "spawnSync"
2124
2225@val @scope ("process" )
2326external exit : int => unit = "exit"
@@ -68,29 +71,21 @@ switch args->Belt.List.fromArray {
6871 switch rest {
6972 | list {"-h" | "--help" } => logAndExit (~log = docHelp , ~code = 0 )
7073 | list {filePath } =>
71- let spawn = spawnSync (analysisProdPath , ["extractDocs" , filePath ])
74+ let spawn = spawnSync (analysisProdPath , ["extractDocs" , filePath ], Some ({ stdio : "inherit" }) )
7275
7376 switch spawn .status -> Js .Null .toOption {
74- | Some (code ) if code !== 0 => logAndExit (~log = spawn .stderr -> Buffer .toString , ~code )
75- | Some (code ) => logAndExit (~log = spawn .stdout -> Buffer .toString , ~code )
76- | None => logAndExit (~log = ` error: unexpected error to extract docs for ${filePath}` , ~code = 1 )
77+ | Some (code ) => exit (code )
78+ | None => ()
7779 }
7880 | _ => logAndExit (~log = docHelp , ~code = 1 )
7981 }
8082| list {"reanalyze" , ... rest } =>
8183 let args = ["reanalyze" ]-> Js .Array2 .concat (Belt .List .toArray (rest ))
82- let spawn = spawnSync (analysisProdPath , args )
84+ let spawn = spawnSync (analysisProdPath , args , Some ({ stdio : "inherit" }) )
8385
8486 switch spawn .status -> Js .Null .toOption {
85- | Some (code ) if code !== 0 => logAndExit (~log = spawn .stderr -> Buffer .toString , ~code )
86- | Some (code ) => logAndExit (~log = spawn .stdout -> Buffer .toString , ~code )
87- | None =>
88- logAndExit (
89- ~log = ` error: unexpected error to run reanalyze with arguments: ${args-> Js.Array2.joinWith(
90- " " ,
91- )}` ,
92- ~code = 1 ,
93- )
87+ | Some (code ) => exit (code )
88+ | None => ()
9489 }
9590| list {"-h" | "--help" } => logAndExit (~log = help , ~code = 0 )
9691| list {"-v" | "--version" } =>
0 commit comments