Skip to content

Commit 925359d

Browse files
committed
Update to latest gren-lang packages.
1 parent af23764 commit 925359d

File tree

6 files changed

+42
-57
lines changed

6 files changed

+42
-57
lines changed

gren.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"dependencies": {
99
"direct": {
1010
"gren-lang/core": "local:../core",
11-
"gren-lang/node": "5.0.4",
11+
"gren-lang/node": "local:../node",
1212
"gren-lang/compiler-node": "local:../compiler-node"
1313
},
1414
"indirect": {

src/Main.gren

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,14 @@ type Msg
152152
}
153153
| CompilerDownloaded
154154
{ localPath : Path
155-
, downloadResult : Result (HttpClient.Error Bytes) (HttpClient.Response Bytes)
155+
, downloadResult : Result HttpClient.Error (HttpClient.Response Bytes)
156156
}
157157
| CompilerInstalled (Result FileSystem.Error Path)
158158
| CompilerInitialized { quiet : Bool, backendStreams : ChildProcess.StreamIO, encodedCommand : Bytes }
159159
| CompilerRan Int
160160
| CompilerRanStatic { path : String, exitCode : Int }
161161
| CompiledForRun { path : String, exitCode : Int }
162-
| RunStarted { processId : Process.Id, streams : Maybe ChildProcess.StreamIO }
162+
| RunStarted { processId : Process.Id, streams : ChildProcess.StreamIO }
163163
| RunExited Int
164164

165165

@@ -268,15 +268,13 @@ update msg model =
268268

269269
CompilerRan exitCode ->
270270
Node.exitWithCode exitCode
271-
|> Task.execute
272271

273272
CompilerRanStatic { path, exitCode } ->
274273
if exitCode == 0 then
275274
completeStaticBuild path
276275

277276
else
278277
Node.exitWithCode exitCode
279-
|> Task.execute
280278

281279
CompiledForRun { path, exitCode } ->
282280
if exitCode == 0 then
@@ -289,14 +287,12 @@ update msg model =
289287

290288
else
291289
Node.exitWithCode exitCode
292-
|> Task.execute
293290

294291
RunStarted _ ->
295292
Cmd.none
296293

297294
RunExited exitCode ->
298295
Node.exitWithCode exitCode
299-
|> Task.execute
300296
}
301297

302298

@@ -343,23 +339,18 @@ parseUserArgs model compilerPath =
343339

344340
CLI.Parser.Success parsedCommand ->
345341
let
346-
initWithCommand backendCommand cpOpts =
347-
when cpOpts.streams is
348-
Nothing ->
349-
-- TODO: error handling
350-
Debug.todo "no stream for child process"
351-
352-
Just streams ->
353-
CompilerInitialized
354-
{ backendStreams = streams
355-
, quiet = False
356-
, encodedCommand =
357-
Compiler.Backend.encodeCommand
358-
{ interactiveSession = model.interactive
359-
, pathToString = model.pathToString
360-
}
361-
backendCommand
362-
}
342+
initWithCommand backendCommand =
343+
ChildProcess.External <| \cpOpts ->
344+
CompilerInitialized
345+
{ backendStreams = cpOpts.streams
346+
, quiet = False
347+
, encodedCommand =
348+
Compiler.Backend.encodeCommand
349+
{ interactiveSession = model.interactive
350+
, pathToString = model.pathToString
351+
}
352+
backendCommand
353+
}
363354
in
364355
when parsedCommand is
365356
CliParser.Init flags ->
@@ -398,7 +389,7 @@ parseUserArgs model compilerPath =
398389
{ useColor = model.useColor
399390
, compilerPath = compilerPath
400391
, pathToString = model.pathToString
401-
, onInit =
392+
, connection =
402393
initWithCommand <|
403394
Compiler.Backend.Repl
404395
{ interpreter = flags.interpreter
@@ -439,7 +430,7 @@ parseUserArgs model compilerPath =
439430
{ useColor = model.useColor
440431
, compilerPath = compilerPath
441432
, pathToString = model.pathToString
442-
, onInit = initWithCommand <|
433+
, connection = initWithCommand <|
443434
Compiler.Backend.Make
444435
{ optimize = flags.optimize
445436
, sourcemaps = flags.sourcemaps
@@ -485,7 +476,7 @@ parseUserArgs model compilerPath =
485476
{ useColor = model.useColor
486477
, compilerPath = compilerPath
487478
, pathToString = model.pathToString
488-
, onInit = initWithCommand <|
479+
, connection = initWithCommand <|
489480
Compiler.Backend.Make
490481
{ optimize = True
491482
, sourcemaps = False
@@ -524,16 +515,11 @@ parseUserArgs model compilerPath =
524515
, moduleName = moduleName
525516
, onBackendInitialized =
526517
(\{ backendStreams, encodedCommand } ->
527-
when backendStreams is
528-
Nothing ->
529-
Debug.todo "no backend streams"
530-
531-
Just streams ->
532-
CompilerInitialized
533-
{ backendStreams = streams
534-
, encodedCommand = encodedCommand
535-
, quiet = True
536-
}
518+
CompilerInitialized
519+
{ backendStreams = backendStreams
520+
, encodedCommand = encodedCommand
521+
, quiet = True
522+
}
537523
)
538524
, onCompiled =
539525
(\outputPath exitCode ->
@@ -575,7 +561,7 @@ parseUserArgs model compilerPath =
575561
{ useColor = model.useColor
576562
, compilerPath = compilerPath
577563
, pathToString = model.pathToString
578-
, onInit =
564+
, connection =
579565
initWithCommand <|
580566
Compiler.Backend.Docs
581567
{ output = flags.output
@@ -762,7 +748,7 @@ parseUserArgs model compilerPath =
762748
(\backendFlags ->
763749
Compiler.Backend.run
764750
model.cpPermission
765-
{ onInit =
751+
{ connection =
766752
initWithCommand <|
767753
Compiler.Backend.PackageBump backendFlags
768754
, useColor = model.useColor
@@ -848,7 +834,7 @@ parseUserArgs model compilerPath =
848834
(\backendFlags ->
849835
Compiler.Backend.run
850836
model.cpPermission
851-
{ onInit =
837+
{ connection =
852838
initWithCommand <|
853839
Compiler.Backend.PackageDiff backendFlags
854840
, useColor = model.useColor

src/Terminal/PackageBump.gren

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ run config { projectPath, outline } =
109109
repoPath =
110110
Terminal.PackageInstall.localRepoPath packageName packageVersion projectPath
111111
in
112-
FileSystem.remove config.fsPermission { recursive = True, ignoreErrors = False } repoPath
112+
FileSystem.remove config.fsPermission { recursive = True } repoPath
113113
|> Task.onError (\_ -> Task.succeed repoPath) -- Probably because directory doesn't exist, that's fine
114114
|> Task.andThen (\_ -> Git.clonePackage config.cpPermission repoPath packageName packageVersion)
115115
|> Task.mapError (\{ stderr } -> Maybe.withDefault "" <| Bytes.toString stderr)

src/Terminal/PackageDiff.gren

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ installHiddenProject config projectPath packageName packageVersion =
158158
repoPath =
159159
Terminal.PackageInstall.localRepoPath packageName packageVersion projectPath
160160
in
161-
FileSystem.remove config.fsPermission { recursive = True, ignoreErrors = False } repoPath
161+
FileSystem.remove config.fsPermission { recursive = True } repoPath
162162
|> Task.onError (\_ -> Task.succeed repoPath) -- Probably because directory doesn't exist, that's fine
163163
|> Task.andThen (\_ -> Git.clonePackage config.cpPermission repoPath packageName packageVersion)
164164
|> Task.mapError (\{ stderr } -> Maybe.withDefault "" <| Bytes.toString stderr)

src/Terminal/PackageInstall.gren

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ installStep config { projectPath, outline, projectSources, rootPackages, loadedP
239239
repoPath =
240240
localRepoPath name lowerBound projectPath
241241
in
242-
FileSystem.remove config.fsPermission { recursive = True, ignoreErrors = False } repoPath
242+
FileSystem.remove config.fsPermission { recursive = True } repoPath
243243
|> Task.onError (\_ -> Task.succeed repoPath) -- Probably because directory doesn't exist, that's fine
244244
|> Task.andThen (\_ -> Git.clonePackage config.cpPermission repoPath name lowerBound)
245245
|> Task.mapError (\{ stderr } -> Maybe.withDefault "" <| Bytes.toString stderr)
@@ -296,7 +296,7 @@ installStep config { projectPath, outline, projectSources, rootPackages, loadedP
296296
else
297297
Task.fail err
298298
)
299-
|> Task.andThen (\_ -> FileSystem.writeFileStream config.fsPermission bundlePath)
299+
|> Task.andThen (\_ -> FileSystem.writeFileStream config.fsPermission FileSystem.Replace bundlePath)
300300
|> Task.mapError FileSystem.errorToString
301301
|> Task.andThen
302302
(\stream ->
@@ -630,7 +630,7 @@ loadPackageFromPath fsPermission name path =
630630
loadPackageFromBundle : FileSystem.Permission -> PackageName -> SemanticVersion -> Path -> Task String (Maybe LoadedPackage)
631631
loadPackageFromBundle fsPermission name vsn projectPath =
632632
packageBundlePath name vsn projectPath
633-
|> FileSystem.readFileStream fsPermission
633+
|> FileSystem.readFileStream fsPermission FileSystem.Beginning
634634
|> Task.mapError FileSystem.errorToString
635635
|> Task.andThen
636636
(\stream ->

src/Terminal/Run.gren

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,15 @@ type alias MakeConfig msg =
3232
, compilerPath : Path
3333
, pathToString : Path -> String
3434
, moduleName : ModuleName
35-
, onBackendInitialized : { backendStreams : Maybe ChildProcess.StreamIO, encodedCommand : Bytes } -> msg
35+
, onBackendInitialized : { backendStreams : ChildProcess.StreamIO, encodedCommand : Bytes } -> msg
3636
, onCompiled : Path -> Int -> msg
3737
}
3838

3939

4040
type alias RunConfig msg =
4141
{ cpPermission : ChildProcess.Permission
4242
, path : String
43-
, onInit :
44-
{ processId : Process.Id, streams : Maybe ChildProcess.StreamIO }
45-
-> msg
43+
, onInit : { processId : Process.Id, streams : ChildProcess.StreamIO } -> msg
4644
, onExit : Int -> msg
4745
}
4846

@@ -95,13 +93,14 @@ make config =
9593
{ useColor = config.useColor
9694
, compilerPath = config.compilerPath
9795
, pathToString = config.pathToString
98-
, onInit =
99-
(\cpOpts ->
100-
config.onBackendInitialized
101-
{ backendStreams = cpOpts.streams
102-
, encodedCommand = encodedCommand_
103-
}
104-
)
96+
, connection =
97+
ChildProcess.External
98+
(\cpOpts ->
99+
config.onBackendInitialized
100+
{ backendStreams = cpOpts.streams
101+
, encodedCommand = encodedCommand_
102+
}
103+
)
105104
, onComplete = config.onCompiled outputPath
106105
}
107106
in
@@ -125,7 +124,7 @@ getOutputPath fsPermission =
125124
run : RunConfig msg -> Cmd msg
126125
run config =
127126
ChildProcess.spawn config.cpPermission "node" [ config.path ] <|
128-
ChildProcess.defaultSpawnOptions config.onInit config.onExit
127+
ChildProcess.defaultSpawnOptions (ChildProcess.External config.onInit) config.onExit
129128

130129

131130
-- not sure if this is the best way to do this?

0 commit comments

Comments
 (0)