@@ -3501,7 +3501,7 @@ var $gren_lang$node$FileSystem$Path$prepend = F2(function(left, right) {
3501
3501
var $gren_lang$node$FileSystem$Path$append = F2 ( function ( left , right ) {
3502
3502
return A2 ( $gren_lang$node$FileSystem$Path$prepend , right , left ) ;
3503
3503
} ) ;
3504
- var $author$project$Main$compilerVersion = '0.4.3 ' ;
3504
+ var $author$project$Main$compilerVersion = '0.4.4 ' ;
3505
3505
var $gren_lang$core$Maybe$map = F2 ( function ( f , maybe ) {
3506
3506
if ( maybe . $ === 'Just' ) {
3507
3507
var value = maybe . a ;
@@ -3929,9 +3929,6 @@ var $gren_lang$core$Json$Decode$succeed = _Json_succeed;
3929
3929
var $author$project$Main$CompilerDownloaded = function ( a ) {
3930
3930
return { $ : 'CompilerDownloaded' , a : a } ;
3931
3931
} ;
3932
- var $author$project$Main$CompilerExecuted = function ( a ) {
3933
- return { $ : 'CompilerExecuted' , a : a } ;
3934
- } ;
3935
3932
var $author$project$Main$CompilerInstalled = function ( a ) {
3936
3933
return { $ : 'CompilerInstalled' , a : a } ;
3937
3934
} ;
@@ -4459,9 +4456,6 @@ var $gren_lang$node$HttpClient$errorToString = function(err) {
4459
4456
return _Utils_ap ( 'Unknown error: ' , debugStr ) ;
4460
4457
}
4461
4458
} ;
4462
- var $gren_lang$node$Node$exitWithCode = function ( code ) {
4463
- return _Node_exitWithCode ( code ) ;
4464
- } ;
4465
4459
var $gren_lang$node$FileSystem$makeDirectory = F3 ( function ( _v0 , options , path ) {
4466
4460
return A2 ( _FileSystem_makeDirectory , options , path ) ;
4467
4461
} ) ;
@@ -4514,8 +4508,12 @@ var $gren_lang$node$ChildProcess$MergeWithEnvironmentVariables = function (a) {
4514
4508
var $gren_lang$node$ChildProcess$DefaultShell = { $ : 'DefaultShell' } ;
4515
4509
var $gren_lang$node$ChildProcess$InheritEnvironmentVariables = { $ : 'InheritEnvironmentVariables' } ;
4516
4510
var $gren_lang$node$ChildProcess$InheritWorkingDirectory = { $ : 'InheritWorkingDirectory' } ;
4511
+ var $gren_lang$node$ChildProcess$Integrated = { $ : 'Integrated' } ;
4517
4512
var $gren_lang$node$ChildProcess$NoLimit = { $ : 'NoLimit' } ;
4518
- var $gren_lang$node$ChildProcess$defaultRunOptions = { environmentVariables : $gren_lang$node$ChildProcess$InheritEnvironmentVariables , maximumBytesWrittenToStreams : 1024 * 1024 , runDuration : $gren_lang$node$ChildProcess$NoLimit , shell : $gren_lang$node$ChildProcess$DefaultShell , workingDirectory : $gren_lang$node$ChildProcess$InheritWorkingDirectory } ;
4513
+ var $gren_lang$node$ChildProcess$defaultSpawnOptions = { connection : $gren_lang$node$ChildProcess$Integrated , environmentVariables : $gren_lang$node$ChildProcess$InheritEnvironmentVariables , runDuration : $gren_lang$node$ChildProcess$NoLimit , shell : $gren_lang$node$ChildProcess$DefaultShell , workingDirectory : $gren_lang$node$ChildProcess$InheritWorkingDirectory } ;
4514
+ var $gren_lang$core$Dict$singleton = F2 ( function ( key , value ) {
4515
+ return A5 ( $gren_lang$core$Dict$RBNode_gren_builtin , $gren_lang$core$Dict$Black , key , value , $gren_lang$core$Dict$RBEmpty_gren_builtin , $gren_lang$core$Dict$RBEmpty_gren_builtin ) ;
4516
+ } ) ;
4519
4517
4520
4518
4521
4519
var bufferNs = require ( "node:buffer" ) ;
@@ -4533,21 +4531,12 @@ var _ChildProcess_run = function (options) {
4533
4531
options . _arguments ,
4534
4532
{
4535
4533
encoding : "buffer" ,
4536
- cwd : workingDir . inherit ? process . cwd ( ) : workingDir . override ,
4537
- env :
4538
- env . option === 0
4539
- ? process . env
4540
- : env . option === 1
4541
- ? _Utils_update ( process . env , _ChildProcess_dictToObj ( env . value ) )
4542
- : _ChildProcess_dictToObj ( env . value ) ,
4534
+ timeout : options . runDuration ,
4535
+ cwd : _ChildProcess_handleCwd ( workingDir ) ,
4536
+ env : _ChildProcess_handleEnv ( env ) ,
4543
4537
timeout : options . runDuration ,
4544
4538
maxBuffer : options . maximumBytesWrittenToStreams ,
4545
- shell :
4546
- shell . choice === 0
4547
- ? false
4548
- : shell . choice === 1
4549
- ? true
4550
- : shell . value ,
4539
+ shell : _ChildProcess_handleShell ( shell ) ,
4551
4540
} ,
4552
4541
function ( err , stdout , stderr ) {
4553
4542
if ( err == null ) {
@@ -4588,6 +4577,51 @@ var _ChildProcess_run = function (options) {
4588
4577
} ) ;
4589
4578
} ;
4590
4579
4580
+ var _ChildProcess_spawn = function ( options ) {
4581
+ return _Scheduler_binding ( function ( callback ) {
4582
+ var workingDir = options . workingDirectory ;
4583
+ var env = options . environmentVariables ;
4584
+ var shell = options . shell ;
4585
+
4586
+ var subproc = childProcess . spawn ( options . program , options . _arguments , {
4587
+ cwd : _ChildProcess_handleCwd ( workingDir ) ,
4588
+ env : _ChildProcess_handleEnv ( env ) ,
4589
+ timeout : options . runDuration ,
4590
+ shell : _ChildProcess_handleShell ( shell ) ,
4591
+ stdio : options . connection === 0 ? "inherit" : "ignore" ,
4592
+ detached : options . connection === 2 && process . platform === "win32" ,
4593
+ } ) ;
4594
+
4595
+ if ( options . connection === 2 ) {
4596
+ subproc . unref ( ) ;
4597
+ }
4598
+
4599
+ return function ( ) {
4600
+ subproc . kill ( ) ;
4601
+ } ;
4602
+ } ) ;
4603
+ } ;
4604
+
4605
+ function _ChildProcess_handleCwd ( cwd ) {
4606
+ return cwd . inherit ? process . cwd ( ) : cwd . override ;
4607
+ }
4608
+
4609
+ function _ChildProcess_handleEnv ( env ) {
4610
+ return env . option === 0
4611
+ ? process . env
4612
+ : env . option === 1
4613
+ ? _Utils_update ( process . env , _ChildProcess_dictToObj ( env . value ) )
4614
+ : _ChildProcess_dictToObj ( env . value ) ;
4615
+ }
4616
+
4617
+ function _ChildProcess_handleShell ( shell ) {
4618
+ return shell . choice === 0
4619
+ ? false
4620
+ : shell . choice === 1
4621
+ ? true
4622
+ : shell . value ;
4623
+ }
4624
+
4591
4625
function _ChildProcess_dictToObj ( dict ) {
4592
4626
return A3 (
4593
4627
$gren_lang$core$Dict$foldl ,
@@ -4603,54 +4637,62 @@ var $gren_lang$core$Basics$gt = _Utils_gt;
4603
4637
var $gren_lang$core$Basics$max = F2 ( function ( x , y ) {
4604
4638
return ( _Utils_cmp ( x , y ) > 0 ) ? x : y ;
4605
4639
} ) ;
4606
- var $gren_lang$node$ChildProcess$run = F4 ( function ( _v0 , program , _arguments , opts ) {
4607
- return _ChildProcess_run ( { _arguments : _arguments , environmentVariables : function ( ) {
4608
- var _v1 = opts . environmentVariables ;
4609
- switch ( _v1 . $ ) {
4610
- case 'InheritEnvironmentVariables' :
4611
- return { option : 0 , value : $gren_lang$core$Dict$empty } ;
4612
- case 'MergeWithEnvironmentVariables' :
4613
- var value = _v1 . a ;
4614
- return { option : 1 , value : value } ;
4615
- default :
4616
- var value = _v1 . a ;
4617
- return { option : 2 , value : value } ;
4618
- }
4619
- } ( ) , maximumBytesWrittenToStreams : opts . maximumBytesWrittenToStreams , program : program , runDuration : function ( ) {
4620
- var _v2 = opts . runDuration ;
4621
- if ( _v2 . $ === 'NoLimit' ) {
4622
- return 0 ;
4623
- } else {
4624
- var ms = _v2 . a ;
4625
- return A2 ( $gren_lang$core$Basics$max , 0 , ms ) ;
4626
- }
4627
- } ( ) , shell : function ( ) {
4628
- var _v3 = opts . shell ;
4629
- switch ( _v3 . $ ) {
4630
- case 'NoShell' :
4631
- return { choice : 0 , value : '' } ;
4632
- case 'DefaultShell' :
4633
- return { choice : 1 , value : '' } ;
4634
- default :
4635
- var value = _v3 . a ;
4636
- return { choice : 2 , value : value } ;
4637
- }
4638
- } ( ) , workingDirectory : function ( ) {
4639
- var _v4 = opts . workingDirectory ;
4640
- if ( _v4 . $ === 'InheritWorkingDirectory' ) {
4641
- return { inherit : true , override : '' } ;
4642
- } else {
4643
- var value = _v4 . a ;
4644
- return { inherit : false , override : value } ;
4645
- }
4646
- } ( ) } ) ;
4647
- } ) ;
4648
- var $gren_lang$core$Dict$singleton = F2 ( function ( key , value ) {
4649
- return A5 ( $gren_lang$core$Dict$RBNode_gren_builtin , $gren_lang$core$Dict$Black , key , value , $gren_lang$core$Dict$RBEmpty_gren_builtin , $gren_lang$core$Dict$RBEmpty_gren_builtin ) ;
4640
+ var $gren_lang$core$Process$spawn = _Scheduler_spawn ;
4641
+ var $gren_lang$node$ChildProcess$spawn = F4 ( function ( _v0 , program , _arguments , opts ) {
4642
+ return $gren_lang$core$Process$spawn ( _ChildProcess_spawn ( { _arguments : _arguments , connection : function ( ) {
4643
+ var _v1 = opts . connection ;
4644
+ switch ( _v1 . $ ) {
4645
+ case 'Integrated' :
4646
+ return 0 ;
4647
+ case 'Ignored' :
4648
+ return 1 ;
4649
+ default :
4650
+ return 2 ;
4651
+ }
4652
+ } ( ) , environmentVariables : function ( ) {
4653
+ var _v2 = opts . environmentVariables ;
4654
+ switch ( _v2 . $ ) {
4655
+ case 'InheritEnvironmentVariables' :
4656
+ return { option : 0 , value : $gren_lang$core$Dict$empty } ;
4657
+ case 'MergeWithEnvironmentVariables' :
4658
+ var value = _v2 . a ;
4659
+ return { option : 1 , value : value } ;
4660
+ default :
4661
+ var value = _v2 . a ;
4662
+ return { option : 2 , value : value } ;
4663
+ }
4664
+ } ( ) , program : program , runDuration : function ( ) {
4665
+ var _v3 = opts . runDuration ;
4666
+ if ( _v3 . $ === 'NoLimit' ) {
4667
+ return 0 ;
4668
+ } else {
4669
+ var ms = _v3 . a ;
4670
+ return A2 ( $gren_lang$core$Basics$max , 0 , ms ) ;
4671
+ }
4672
+ } ( ) , shell : function ( ) {
4673
+ var _v4 = opts . shell ;
4674
+ switch ( _v4 . $ ) {
4675
+ case 'NoShell' :
4676
+ return { choice : 0 , value : '' } ;
4677
+ case 'DefaultShell' :
4678
+ return { choice : 1 , value : '' } ;
4679
+ default :
4680
+ var value = _v4 . a ;
4681
+ return { choice : 2 , value : value } ;
4682
+ }
4683
+ } ( ) , workingDirectory : function ( ) {
4684
+ var _v5 = opts . workingDirectory ;
4685
+ if ( _v5 . $ === 'InheritWorkingDirectory' ) {
4686
+ return { inherit : true , override : '' } ;
4687
+ } else {
4688
+ var value = _v5 . a ;
4689
+ return { inherit : false , override : value } ;
4690
+ }
4691
+ } ( ) } ) ) ;
4650
4692
} ) ;
4651
4693
var $author$project$Main$runCompiler = function ( model ) {
4652
4694
var colorEnvVar = model . useColor ? A2 ( $gren_lang$core$Dict$singleton , 'FORCE_COLOR' , '1' ) : A2 ( $gren_lang$core$Dict$singleton , 'NO_COLOR' , '1' ) ;
4653
- return A4 ( $gren_lang$node$ChildProcess$run , model . cpPermission , model . pathToString ( model . localPath ) , model . args , _Utils_update ( $gren_lang$node$ChildProcess$defaultRunOptions , { environmentVariables : $gren_lang$node$ChildProcess$MergeWithEnvironmentVariables ( colorEnvVar ) , maximumBytesWrittenToStreams : 1024 * 1024 } ) ) ;
4695
+ return A4 ( $gren_lang$node$ChildProcess$spawn , model . cpPermission , model . pathToString ( model . localPath ) , model . args , _Utils_update ( $gren_lang$node$ChildProcess$defaultSpawnOptions , { environmentVariables : $gren_lang$node$ChildProcess$MergeWithEnvironmentVariables ( colorEnvVar ) } ) ) ;
4654
4696
} ;
4655
4697
var $gren_lang$node$FileSystem$writeFile = F3 ( function ( _v0 , bytes , path ) {
4656
4698
return A2 ( _FileSystem_writeFile , bytes , path ) ;
@@ -4671,7 +4713,7 @@ var $author$project$Main$update = F2(function(msg, model) {
4671
4713
}
4672
4714
} ( ) , model : model } ;
4673
4715
} else {
4674
- return { command : A2 ( $gren_lang$core$Task$attempt , $author$project$Main$CompilerExecuted , $author$project$Main$runCompiler ( model ) ) , model : model } ;
4716
+ return { command : $gren_lang$core$Task$execute ( $author$project$Main$runCompiler ( model ) ) , model : model } ;
4675
4717
}
4676
4718
case 'CompilerDownloaded' :
4677
4719
if ( msg . a . $ === 'Err' ) {
@@ -4702,24 +4744,12 @@ var $author$project$Main$update = F2(function(msg, model) {
4702
4744
return A3 ( $gren_lang$node$FileSystem$writeFile , model . fsPermission , res . data , model . localPath ) ;
4703
4745
} , A3 ( $gren_lang$node$FileSystem$makeDirectory , model . fsPermission , { recursive : true } , cacheFolder ) ) ) ) ) , model : model } ;
4704
4746
}
4705
- case 'CompilerInstalled' :
4747
+ default :
4706
4748
if ( msg . a . $ === 'Err' ) {
4707
4749
var fsErr = msg . a . a ;
4708
4750
return { command : $gren_lang$core$Task$execute ( A2 ( $gren_lang$node$Stream$sendLine , model . stderr , _Utils_ap ( 'Failed to install binary after download, due to error: ' , $gren_lang$node$FileSystem$errorToString ( fsErr ) ) ) ) , model : model } ;
4709
4751
} else {
4710
- return { command : A2 ( $gren_lang$core$Task$attempt , $author$project$Main$CompilerExecuted , $author$project$Main$runCompiler ( model ) ) , model : model } ;
4711
- }
4712
- default :
4713
- if ( msg . a . $ === 'Err' ) {
4714
- var output = msg . a . a ;
4715
- return { command : $gren_lang$core$Task$execute ( A2 ( $gren_lang$core$Task$andThen , function ( _v6 ) {
4716
- return $gren_lang$node$Node$exitWithCode ( output . exitCode ) ;
4717
- } , A2 ( $gren_lang$node$Stream$send , model . stderr , output . stderr ) ) ) , model : model } ;
4718
- } else {
4719
- var output = msg . a . a ;
4720
- return { command : $gren_lang$core$Task$execute ( A2 ( $gren_lang$core$Task$andThen , function ( _v7 ) {
4721
- return A2 ( $gren_lang$node$Stream$send , model . stderr , output . stderr ) ;
4722
- } , A2 ( $gren_lang$node$Stream$send , model . stdout , output . stdout ) ) ) , model : model } ;
4752
+ return { command : $gren_lang$core$Task$execute ( $author$project$Main$runCompiler ( model ) ) , model : model } ;
4723
4753
}
4724
4754
}
4725
4755
} ) ;
0 commit comments