@@ -40,6 +40,8 @@ module Node = {
4040 @send
4141 external once : (spawnReturns , string , (Js .Null .t <float >, Js .Null .t <string >) => unit ) => unit =
4242 "once"
43+ @send
44+ external onceError : (spawnReturns , string , Js .Exn .t => unit ) => unit = "once"
4345 }
4446
4547 module OS = {
@@ -92,17 +94,20 @@ module SpawnAsync = {
9294 code : Null .t <float >,
9395 }
9496 let run = async (~command , ~args , ~options = ?) => {
95- await Promise .make ((resolve , _reject ) => {
96- let spawn = ChildProcess .spawn (command , args , ~options ?)
97- let stdout = []
98- let stderr = []
99- spawn .stdout -> ChildProcess .on ("data" , data => {
100- Array .push (stdout , data )
101- })
102- spawn .stderr -> ChildProcess .on ("data" , data => {
103- Array .push (stderr , data )
97+ let spawn = ChildProcess .spawn (command , args , ~options ?)
98+ let stdout = []
99+ let stderr = []
100+ spawn .stdout -> ChildProcess .on ("data" , data => {
101+ Array .push (stdout , data )
102+ })
103+ spawn .stderr -> ChildProcess .on ("data" , data => {
104+ Array .push (stderr , data )
105+ })
106+ await Promise .make ((resolve , reject ) => {
107+ spawn -> ChildProcess .once ("error" , (_ , _ ) => {
108+ reject ({stdout , stderr , code : Null .make (1.0 )})
104109 })
105- spawn -> ChildProcess .onFromSpawn ("close" , code => {
110+ spawn -> ChildProcess .once ("close" , ( code , _signal ) => {
106111 resolve ({stdout , stderr , code })
107112 })
108113 })
@@ -374,8 +379,6 @@ let main = async () => {
374379 // Await the next iterator value
375380 let {value , done } = await asyncIterator -> AsyncIterator .next
376381
377- Console .log2 (value , Array .length (chuncks ))
378-
379382 // Exit the while loop if the iterator says it's done
380383 break := done
381384
@@ -402,6 +405,8 @@ let main = async () => {
402405
403406 let () = await processMyAsyncIterator ()
404407
408+ Console .log ("Compiation tests finished" )
409+
405410 let compilationResults = result -> Array .flat
406411
407412 // let compilationResults =
0 commit comments