Skip to content

Commit a600e28

Browse files
authored
Merge pull request #14 from revathskumar/upgrade-gren-node
cat: upgrade gren-lang/node to 3.0.1
2 parents 7bb41ed + 28d8a67 commit a600e28

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

cat/gren.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
"gren-version": "0.3.0",
88
"dependencies": {
99
"direct": {
10-
"gren-lang/core": "4.0.0",
11-
"gren-lang/node": "2.0.0"
10+
"gren-lang/core": "4.0.1",
11+
"gren-lang/node": "3.0.1"
1212
},
13-
"indirect": {}
13+
"indirect": {
14+
"gren-lang/url": "3.0.0"
15+
}
1416
}
1517
}

cat/src/Main.gren

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ module Main exposing (main)
33
import Node
44
import Bytes exposing (Bytes)
55
import Stream exposing (Stream)
6-
import Node.Program as Program exposing (Program)
6+
import Node exposing (Program, Environment)
77
import FileSystem
8+
import Init
89
import Task
910

1011

1112
main : Program Model Msg
1213
main =
13-
Program.define
14+
Node.defineProgram
1415
{ init = init
1516
, update = update
1617
, subscriptions = \_ -> Sub.none
@@ -27,27 +28,24 @@ type Msg
2728
= OpenResult (Result FileSystem.AccessError (FileSystem.ReadableFileHandle Never))
2829
| ReadResult (Result FileSystem.UnknownFileSystemError Bytes)
2930

30-
31-
init : Program.AppInitTask { model : Model, command : Cmd Msg }
32-
init =
33-
Program.await Node.initialize <| \nodeConfig ->
34-
Program.await FileSystem.initialize <| \fsPermission ->
35-
Program.startProgram
36-
{ model =
37-
{ stdout = nodeConfig.stdout
38-
, stderr = nodeConfig.stderr
39-
}
40-
, command =
41-
case nodeConfig.args of
42-
[ _, _, file ] ->
43-
FileSystem.openForRead fsPermission file
44-
|> Task.attempt OpenResult
45-
46-
_ ->
47-
Stream.sendLine nodeConfig.stderr <|
48-
"Exactly one argument is required: the file name to read"
31+
init : Environment -> Init.Task { model : Model, command : Cmd Msg }
32+
init env =
33+
Init.await FileSystem.initialize <| \fsPermission ->
34+
Node.startProgram
35+
{ model =
36+
{ stdout = env.stdout
37+
, stderr = env.stderr
4938
}
50-
39+
, command =
40+
case env.args of
41+
[ _, _, file ] ->
42+
FileSystem.openForRead fsPermission file
43+
|> Task.attempt OpenResult
44+
45+
_ ->
46+
Stream.sendLine env.stderr <|
47+
"Exactly one argument is required: the file name to read"
48+
}
5149

5250
update : Msg -> Model -> { model : Model, command : Cmd Msg }
5351
update msg model =

0 commit comments

Comments
 (0)