Skip to content

Prep repo for breaking changes #74

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 9 commits into from
Jul 8, 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
11 changes: 8 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: purescript-contrib/setup-purescript@main
with:
purescript: "unstable"
purs-tidy: "latest"

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: "14"
node-version: "lts/*"

- name: Install dependencies
run: |
Expand All @@ -33,3 +34,7 @@ jobs:
run: |
bower install
npm run-script test --if-present

- name: Check formatting
run: |
purs-tidy check src test
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ New features:
Bugfixes:

Other improvements:
- Update `node-buffer` to next breaking release: `v9.0.0` (#74 by @JordanMartinez)
- Update `node-streams` to next breaking release: `TODO` (#74 by @JordanMartinez)
- Update CI actions to v3 (#74 by @JordanMartinez)
- Update CI node to `lts/*` (#74 by @JordanMartinez)
- Enforce `purs-tidy` format check in CI (#74 by @JordanMartinez)

## [v8.2.0](https://github.com/purescript-node/purescript-node-fs/releases/tag/v8.2.0) - 2023-03-23

Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
"purescript-integers": "^6.0.0",
"purescript-js-date": "^8.0.0",
"purescript-maybe": "^6.0.0",
"purescript-node-buffer": "^8.0.0",
"purescript-node-buffer": "^9.0.0",
"purescript-node-path": "^5.0.0",
"purescript-node-streams": "^7.0.0",
"purescript-node-streams": "#684041e14e56c75c0bf49db0e556aec6d0248e5a",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this hash is only being used so development on this repo can start. This needs to be updated to an actual release before this repo can be released.

"purescript-nullable": "^6.0.0",
"purescript-partial": "^4.0.0",
"purescript-prelude": "^6.0.0",
Expand Down
18 changes: 7 additions & 11 deletions src/Node/FS.purs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module Node.FS
( FileDescriptor(..)
, FileMode(..)
( FileDescriptor
, FileMode
, SymlinkType(..)
, symlinkTypeToNode
, BufferLength(..)
, BufferOffset(..)
, ByteCount(..)
, FilePosition(..)
, BufferLength
, BufferOffset
, ByteCount
, FilePosition
, module Exports
) where

Expand Down Expand Up @@ -38,8 +38,4 @@ instance showSymlinkType :: Show SymlinkType where
show DirLink = "DirLink"
show JunctionLink = "JunctionLink"

instance eqSymlinkType :: Eq SymlinkType where
eq FileLink FileLink = true
eq DirLink DirLink = true
eq JunctionLink JunctionLink = true
eq _ _ = false
derive instance eqSymlinkType :: Eq SymlinkType
2 changes: 1 addition & 1 deletion src/Node/FS/Async.purs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Node.FS.Async
( Callback(..)
( Callback
, access
, access'
, copyFile
Expand Down
8 changes: 2 additions & 6 deletions src/Node/FS/Perms.purs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ import Partial.Unsafe (unsafePartial)
-- | intersection respectively.
newtype Perm = Perm { r :: Boolean, w :: Boolean, x :: Boolean }

instance eqPerm :: Eq Perm where
eq (Perm { r: r1, w: w1, x: x1 }) (Perm { r: r2, w: w2, x: x2 }) =
r1 == r2 && w1 == w2 && x1 == x2
derive newtype instance eqPerm :: Eq Perm

instance ordPerm :: Ord Perm where
compare (Perm { r: r1, w: w1, x: x1 }) (Perm { r: r2, w: w2, x: x2 }) =
Expand Down Expand Up @@ -101,9 +99,7 @@ all = one
-- | file owner, the group, and any other users.
newtype Perms = Perms { u :: Perm, g :: Perm, o :: Perm }

instance eqPerms :: Eq Perms where
eq (Perms { u: u1, g: g1, o: o1 }) (Perms { u: u2, g: g2, o: o2 }) =
u1 == u2 && g1 == g2 && o1 == o2
derive newtype instance eqPerms :: Eq Perms

instance ordPerms :: Ord Perms where
compare (Perms { u: u1, g: g1, o: o1 }) (Perms { u: u2, g: g2, o: o2 }) =
Expand Down
2 changes: 1 addition & 1 deletion src/Node/FS/Stats.purs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Node.FS.Stats
( Stats(..)
, StatsObj(..)
, StatsObj
, isFile
, isDirectory
, isBlockDevice
Expand Down
17 changes: 5 additions & 12 deletions src/Node/FS/Stream.purs
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
module Node.FS.Stream
( createWriteStream
, fdCreateWriteStream
, WriteStreamOptions()
, WriteStreamOptions
, defaultWriteStreamOptions
, createWriteStreamWith
, fdCreateWriteStreamWith
, createReadStream
, fdCreateReadStream
, ReadStreamOptions()
, ReadStreamOptions
, defaultReadStreamOptions
, createReadStreamWith
, fdCreateReadStreamWith
) where

import Prelude

import Data.Maybe (Maybe(..))
import Data.Nullable (Nullable, toNullable)
import Data.Nullable (Nullable, notNull, null)
import Effect (Effect)
import Effect.Uncurried (EffectFn2, runEffectFn2)
import Node.FS (FileDescriptor)
Expand All @@ -34,12 +33,6 @@ readWrite = Perms.mkPerms rw rw rw
where
rw = Perms.read + Perms.write

null :: forall a. Nullable a
null = toNullable Nothing

nonnull :: forall a. a -> Nullable a
nonnull = toNullable <<< Just

-- | Create a Writable stream which writes data to the specified file, using
-- | the default options.
createWriteStream
Expand Down Expand Up @@ -72,7 +65,7 @@ createWriteStreamWith
-> Effect (Writable ())
createWriteStreamWith opts file = runEffectFn2
createWriteStreamImpl
(nonnull file)
(notNull file)
{ mode: Perms.permsToInt opts.perms
, flags: fileFlagsToNode opts.flags
}
Expand Down Expand Up @@ -124,7 +117,7 @@ createReadStreamWith
-> Effect (Readable ())
createReadStreamWith opts file = runEffectFn2
createReadStreamImpl
(nonnull file)
(notNull file)
{ mode: Perms.permsToInt opts.perms
, flags: fileFlagsToNode opts.flags
, autoClose: opts.autoClose
Expand Down
9 changes: 5 additions & 4 deletions test/Streams.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@ import Prelude
import Effect (Effect)
import Effect.Console (log)
import Node.Encoding (Encoding(..))
import Node.Path as Path
import Node.Stream as Stream
import Node.EventEmitter (on_)
import Node.FS.Stream (createWriteStream, createReadStream)
import Node.FS.Sync as Sync
import Node.Path as Path
import Node.Stream as Stream

main :: Effect Unit
main = do
let fp = Path.concat

_ <- log "Testing streams"
log "Testing streams"

r <- createReadStream (fp [ "test", "Streams.purs" ])
w <- createWriteStream (fp [ "tmp", "Streams.purs" ])

_ <- Stream.pipe r w

Stream.onEnd r do
r # on_ Stream.endH do
src <- Sync.readTextFile UTF8 (fp [ "test", "Streams.purs" ])
dst <- Sync.readTextFile UTF8 (fp [ "tmp", "Streams.purs" ])

Expand Down