diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 06ed895..a39bce1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: | @@ -33,3 +34,7 @@ jobs: run: | bower install npm run-script test --if-present + + - name: Check formatting + run: | + purs-tidy check src test diff --git a/CHANGELOG.md b/CHANGELOG.md index 44586b1..e53ccaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/bower.json b/bower.json index 3696b74..69545b6 100644 --- a/bower.json +++ b/bower.json @@ -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", "purescript-nullable": "^6.0.0", "purescript-partial": "^4.0.0", "purescript-prelude": "^6.0.0", diff --git a/src/Node/FS.purs b/src/Node/FS.purs index 11a0c66..2bb3c56 100644 --- a/src/Node/FS.purs +++ b/src/Node/FS.purs @@ -1,12 +1,12 @@ module Node.FS - ( FileDescriptor(..) - , FileMode(..) + ( FileDescriptor + , FileMode , SymlinkType(..) , symlinkTypeToNode - , BufferLength(..) - , BufferOffset(..) - , ByteCount(..) - , FilePosition(..) + , BufferLength + , BufferOffset + , ByteCount + , FilePosition , module Exports ) where @@ -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 diff --git a/src/Node/FS/Async.purs b/src/Node/FS/Async.purs index 8fe33bd..05b04f1 100644 --- a/src/Node/FS/Async.purs +++ b/src/Node/FS/Async.purs @@ -1,5 +1,5 @@ module Node.FS.Async - ( Callback(..) + ( Callback , access , access' , copyFile diff --git a/src/Node/FS/Perms.purs b/src/Node/FS/Perms.purs index a00c458..ce70460 100644 --- a/src/Node/FS/Perms.purs +++ b/src/Node/FS/Perms.purs @@ -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 }) = @@ -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 }) = diff --git a/src/Node/FS/Stats.purs b/src/Node/FS/Stats.purs index 24b5ac7..d3fe67c 100644 --- a/src/Node/FS/Stats.purs +++ b/src/Node/FS/Stats.purs @@ -1,6 +1,6 @@ module Node.FS.Stats ( Stats(..) - , StatsObj(..) + , StatsObj , isFile , isDirectory , isBlockDevice diff --git a/src/Node/FS/Stream.purs b/src/Node/FS/Stream.purs index 5ed7563..0c4468a 100644 --- a/src/Node/FS/Stream.purs +++ b/src/Node/FS/Stream.purs @@ -1,13 +1,13 @@ module Node.FS.Stream ( createWriteStream , fdCreateWriteStream - , WriteStreamOptions() + , WriteStreamOptions , defaultWriteStreamOptions , createWriteStreamWith , fdCreateWriteStreamWith , createReadStream , fdCreateReadStream - , ReadStreamOptions() + , ReadStreamOptions , defaultReadStreamOptions , createReadStreamWith , fdCreateReadStreamWith @@ -15,8 +15,7 @@ module Node.FS.Stream 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) @@ -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 @@ -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 } @@ -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 diff --git a/test/Streams.purs b/test/Streams.purs index 231939f..eef4029 100644 --- a/test/Streams.purs +++ b/test/Streams.purs @@ -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" ])