Skip to content

Commit 143fe1e

Browse files
Ad WriteFileNode (#174)
1 parent 9b95ecd commit 143fe1e

File tree

7 files changed

+44
-0
lines changed

7 files changed

+44
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,4 @@ Running a web-compatible recipe:
120120
| | :heavy_check_mark: | [TimeHalogenHooks](recipes/TimeHalogenHooks) | A Halogen port of the ["Time - Time" Elm Example](https://elm-lang.org/examples/time). |
121121
| | :heavy_check_mark: | [TimeReactHooks](recipes/TimeReactHooks) | A React port of the ["User Interface - Time" Elm Example](https://elm-lang.org/examples/time). |
122122
| | :heavy_check_mark: | [WindowPropertiesJs](recipes/WindowPropertiesJs) | This recipe shows how to get and print various properties in the browser's `window` object. |
123+
| :heavy_check_mark: | | [WriteFileNode](recipes/WriteFileNode) | Writes a `String` to a text file using UTF-8 encoding. |

recipes/WriteFileNode/.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/bower_components/
2+
/node_modules/
3+
/.pulp-cache/
4+
/output/
5+
/generated-docs/
6+
/.psc-package/
7+
/.psc*
8+
/.purs*
9+
/.psa*
10+
/.spago
11+
/web-dist/
12+
/prod-dist/
13+
/prod/
14+
./example.txt

recipes/WriteFileNode/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# WriteFileNode
2+
3+
Writes a `String` to a text file using UTF-8 encoding.
4+
5+
## Expected Behavior:
6+
7+
### Node.js
8+
9+
Creates or overwrites a file called "example.txt" with the content "File content."

recipes/WriteFileNode/example.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
File content
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This file just indicates that the node backend is supported.
2+
It is used for CI and autogeneration purposes.

recipes/WriteFileNode/spago.dhall

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{ name = "WriteFileNode"
2+
, dependencies = [ "console", "effect", "node-fs-aff", "psci-support" ]
3+
, packages = ../../packages.dhall
4+
, sources = [ "recipes/WriteFileNode/src/**/*.purs" ]
5+
}

recipes/WriteFileNode/src/Main.purs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module WriteFileNode.Main where
2+
3+
import Prelude
4+
5+
import Effect (Effect)
6+
import Effect.Aff (launchAff_)
7+
import Node.Encoding (Encoding(..))
8+
import Node.FS.Aff (writeTextFile)
9+
10+
main :: Effect Unit
11+
main = launchAff_ do
12+
writeTextFile UTF8 "./recipes/WriteFileNode/example.txt" "File content."

0 commit comments

Comments
 (0)