Skip to content

Commit 3607325

Browse files
authoredJul 8, 2023
Prep repo for breaking changes (#74)
* Update CI actions, CI node to lts * Bump buffer/streams to master * Update exports to conventions * Enforce purs-tidy formatting * Simplify Nullable usage * Derive Eq instances * Add changelog entry * Don't count dep bumps as breaking * Update usage of `end` event handler
1 parent 24fc929 commit 3607325

File tree

9 files changed

+36
-40
lines changed

9 files changed

+36
-40
lines changed
 

‎.github/workflows/ci.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ jobs:
1010
build:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v3
1414

1515
- uses: purescript-contrib/setup-purescript@main
1616
with:
1717
purescript: "unstable"
18+
purs-tidy: "latest"
1819

19-
- uses: actions/setup-node@v2
20+
- uses: actions/setup-node@v3
2021
with:
21-
node-version: "14"
22+
node-version: "lts/*"
2223

2324
- name: Install dependencies
2425
run: |
@@ -33,3 +34,7 @@ jobs:
3334
run: |
3435
bower install
3536
npm run-script test --if-present
37+
38+
- name: Check formatting
39+
run: |
40+
purs-tidy check src test

‎CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ New features:
1111
Bugfixes:
1212

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

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

‎bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
"purescript-integers": "^6.0.0",
3030
"purescript-js-date": "^8.0.0",
3131
"purescript-maybe": "^6.0.0",
32-
"purescript-node-buffer": "^8.0.0",
32+
"purescript-node-buffer": "^9.0.0",
3333
"purescript-node-path": "^5.0.0",
34-
"purescript-node-streams": "^7.0.0",
34+
"purescript-node-streams": "#684041e14e56c75c0bf49db0e556aec6d0248e5a",
3535
"purescript-nullable": "^6.0.0",
3636
"purescript-partial": "^4.0.0",
3737
"purescript-prelude": "^6.0.0",

‎src/Node/FS.purs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module Node.FS
2-
( FileDescriptor(..)
3-
, FileMode(..)
2+
( FileDescriptor
3+
, FileMode
44
, SymlinkType(..)
55
, symlinkTypeToNode
6-
, BufferLength(..)
7-
, BufferOffset(..)
8-
, ByteCount(..)
9-
, FilePosition(..)
6+
, BufferLength
7+
, BufferOffset
8+
, ByteCount
9+
, FilePosition
1010
, module Exports
1111
) where
1212

@@ -38,8 +38,4 @@ instance showSymlinkType :: Show SymlinkType where
3838
show DirLink = "DirLink"
3939
show JunctionLink = "JunctionLink"
4040

41-
instance eqSymlinkType :: Eq SymlinkType where
42-
eq FileLink FileLink = true
43-
eq DirLink DirLink = true
44-
eq JunctionLink JunctionLink = true
45-
eq _ _ = false
41+
derive instance eqSymlinkType :: Eq SymlinkType

‎src/Node/FS/Async.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Node.FS.Async
2-
( Callback(..)
2+
( Callback
33
, access
44
, access'
55
, copyFile

‎src/Node/FS/Perms.purs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ import Partial.Unsafe (unsafePartial)
4040
-- | intersection respectively.
4141
newtype Perm = Perm { r :: Boolean, w :: Boolean, x :: Boolean }
4242

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

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

104-
instance eqPerms :: Eq Perms where
105-
eq (Perms { u: u1, g: g1, o: o1 }) (Perms { u: u2, g: g2, o: o2 }) =
106-
u1 == u2 && g1 == g2 && o1 == o2
102+
derive newtype instance eqPerms :: Eq Perms
107103

108104
instance ordPerms :: Ord Perms where
109105
compare (Perms { u: u1, g: g1, o: o1 }) (Perms { u: u2, g: g2, o: o2 }) =

‎src/Node/FS/Stats.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Node.FS.Stats
22
( Stats(..)
3-
, StatsObj(..)
3+
, StatsObj
44
, isFile
55
, isDirectory
66
, isBlockDevice

‎src/Node/FS/Stream.purs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
module Node.FS.Stream
22
( createWriteStream
33
, fdCreateWriteStream
4-
, WriteStreamOptions()
4+
, WriteStreamOptions
55
, defaultWriteStreamOptions
66
, createWriteStreamWith
77
, fdCreateWriteStreamWith
88
, createReadStream
99
, fdCreateReadStream
10-
, ReadStreamOptions()
10+
, ReadStreamOptions
1111
, defaultReadStreamOptions
1212
, createReadStreamWith
1313
, fdCreateReadStreamWith
1414
) where
1515

1616
import Prelude
1717

18-
import Data.Maybe (Maybe(..))
19-
import Data.Nullable (Nullable, toNullable)
18+
import Data.Nullable (Nullable, notNull, null)
2019
import Effect (Effect)
2120
import Effect.Uncurried (EffectFn2, runEffectFn2)
2221
import Node.FS (FileDescriptor)
@@ -34,12 +33,6 @@ readWrite = Perms.mkPerms rw rw rw
3433
where
3534
rw = Perms.read + Perms.write
3635

37-
null :: forall a. Nullable a
38-
null = toNullable Nothing
39-
40-
nonnull :: forall a. a -> Nullable a
41-
nonnull = toNullable <<< Just
42-
4336
-- | Create a Writable stream which writes data to the specified file, using
4437
-- | the default options.
4538
createWriteStream
@@ -72,7 +65,7 @@ createWriteStreamWith
7265
-> Effect (Writable ())
7366
createWriteStreamWith opts file = runEffectFn2
7467
createWriteStreamImpl
75-
(nonnull file)
68+
(notNull file)
7669
{ mode: Perms.permsToInt opts.perms
7770
, flags: fileFlagsToNode opts.flags
7871
}
@@ -124,7 +117,7 @@ createReadStreamWith
124117
-> Effect (Readable ())
125118
createReadStreamWith opts file = runEffectFn2
126119
createReadStreamImpl
127-
(nonnull file)
120+
(notNull file)
128121
{ mode: Perms.permsToInt opts.perms
129122
, flags: fileFlagsToNode opts.flags
130123
, autoClose: opts.autoClose

‎test/Streams.purs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,24 @@ import Prelude
55
import Effect (Effect)
66
import Effect.Console (log)
77
import Node.Encoding (Encoding(..))
8-
import Node.Path as Path
9-
import Node.Stream as Stream
8+
import Node.EventEmitter (on_)
109
import Node.FS.Stream (createWriteStream, createReadStream)
1110
import Node.FS.Sync as Sync
11+
import Node.Path as Path
12+
import Node.Stream as Stream
1213

1314
main :: Effect Unit
1415
main = do
1516
let fp = Path.concat
1617

17-
_ <- log "Testing streams"
18+
log "Testing streams"
1819

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

2223
_ <- Stream.pipe r w
2324

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

0 commit comments

Comments
 (0)
Please sign in to comment.