Skip to content

Support rescript v11 #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
- run: yarn install
- run: yarn test
10 changes: 4 additions & 6 deletions bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
],
"suffix": ".bs.js",
"bs-dependencies": [],
"bs-dev-dependencies": [
"@dusty-phillips/rescript-zora",
"@ryyppy/rescript-promise"
],
"bs-dev-dependencies": ["@dusty-phillips/rescript-zora"],
"warnings": {
"number": "A-4-40-41-42-43-44+101-102-103",
"error": "false"
}
}
},
"uncurried": false
}
2 changes: 1 addition & 1 deletion lib/js/examples/ReadFileByLine.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/js/test/atomic/BigInt.test.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions lib/js/test/atomic/BinaryLike.test.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 14 additions & 28 deletions lib/js/test/atomic/Fs.test.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/js/test/atomic/Stream.test.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"description": "Node bindings for ReScript",
"license": "MIT",
"devDependencies": {
"@dusty-phillips/rescript-zora": "^3.0.0",
"@dusty-phillips/rescript-zora": "^4.0.0",
"onchange": "^7.1.0",
"pta": "^1.0.0",
"rescript": "^10.0.1",
"zora": "^5.0.0"
"pta": "^1.2.0",
"rescript": "^11.0.0-beta.3",
"zora": "^5.2.0"
}
}
2 changes: 1 addition & 1 deletion src/Buffer.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type t = Node.buffer
type t
open Js.TypedArray2

module Constants = {
Expand Down
1 change: 1 addition & 0 deletions src/Exports.res
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type t
14 changes: 13 additions & 1 deletion src/Module.res
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
include Node_module
type rec t = {
id: string,
exports: Exports.t,
// in REPL V4 it is `undefined` in CLI it can be `null`
parrent: Js.Nullable.t<t>,
filename: string,
loaded: bool,
children: array<t>,
paths: array<string>,
}

@val
external module_: {"__cache": Js.Dict.t<t>} = "module"
41 changes: 14 additions & 27 deletions test/atomic/Fs.test.res
Original file line number Diff line number Diff line change
@@ -1,35 +1,22 @@
open Fs
open Zora

zora("Fs", t => {
t->test("readFile should read entire file", t => {
open_(Global.filename, Flag.read)
->then(fh =>
FileHandle.readFile(fh)->then(buffer => FileHandle.close(fh)->then(_ => done(buffer)))
)
->then(buffer => {
let needle = "Random string: Gh2e71pdHhPxU"
t->ok(buffer->Buffer.indexOfString(needle) > 1, "buffer index was not greater than zero")
done()
})
zora("Fs", async t => {
t->test("readFile should read entire file", async t => {
let fh = await open_(Global.filename, Flag.read)
let buffer = await FileHandle.readFile(fh)
let _ = await FileHandle.close(fh)

let needle = "Random string: Gh2e71pdHhPxU"
t->ok(buffer->Buffer.indexOfString(needle) > 1, "buffer index was not greater than zero")
})

t->test("readFileWith should read entire file as a string", t => {
open_(Global.filename, Flag.read)
->then(fh =>
FileHandle.readFileWith(fh, readFileOptions(~encoding="UTF-8", ()))->then(buffer =>
FileHandle.close(fh)->then(_ => done(buffer))
)
)
->then(content => {
let needle = "Random string: uCF6c5f3Arrq"
t->test("readFileWith should read entire file as a string", async t => {
let fh = await open_(Global.filename, Flag.read)
let buffer = await FileHandle.readFileWith(fh, readFileOptions(~encoding="UTF-8", ()))
let _ = await FileHandle.close(fh)
let needle = "Random string: uCF6c5f3Arrq"

t->ok(
Js.String.indexOf(needle, content) > 0,
"buffer string indexOf was not greater than zero",
)
done()
})
t->ok(Js.String.indexOf(needle, buffer) > 0, "buffer string indexOf was not greater than zero")
})
done()
})
14 changes: 7 additions & 7 deletions test/atomic/Stream.test.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
open Zora
open StreamTestLib
ti

zoraBlock("Stream.Readable", t => {
t->block("'Stream.Readable.make' should return a defined value", t => {
let readable = makeReadableEmpty()
Expand All @@ -21,15 +21,15 @@ zoraBlock("Stream.Readable", t => {
t->test("'Stream.Readable.destroyWithError' should emit 'error' event", t => {
open! Errors
let dummyError = Error.make("Expected error: Stream destroyed")->Error.toJsExn
Promise.make(
(resolve, _reject) => {
Js.Promise2.make(
(~resolve, ~reject as _) => {
let stream = StreamTestLib.makeReadableEmpty()->Stream.onError(
err => {
t->equal(err, dummyError, "")

// oh these bindings are wonderful aren't they
let a = ()
resolve(. a)
resolve(a)
},
)

Expand Down Expand Up @@ -71,8 +71,8 @@ zoraBlock("Stream.Writable", t => {
(),
)

Promise.make(
(resolve, _reject) => {
Js.Promise2.make(
(~resolve, ~reject as _) => {
let writeStream = Writable.makeObjMode(options)

Writable.writeWith(
Expand All @@ -93,7 +93,7 @@ zoraBlock("Stream.Writable", t => {

// oh these bindings are wonderful aren't they
let a = ()
resolve(. a)
resolve(a)
},
(),
)->ignore
Expand Down
Loading