diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 06ed895..fc3392b 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 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index fe2904a..cb8c299 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,12 +5,16 @@ Notable changes to this project are documented in this file. The format is based ## [Unreleased] Breaking changes: +- Update `node-buffer` to `v9.0.0` (#48 by @JordanMartinez) New features: Bugfixes: Other improvements: +- Bumped CI's node version to `lts/*` (#48 by @JordanMartinez) +- Updated CI `actions/checkout` and `actions/setup-nodee` to `v3` (#48 by @JordanMartinez) +- Format code via purs-tidy; enforce formatting via CI (#48 by @JordanMartinez) ## [v7.0.0](https://github.com/purescript-node/purescript-node-streams/releases/tag/v7.0.0) - 2022-04-29 diff --git a/bower.json b/bower.json index be709a7..81d651d 100644 --- a/bower.json +++ b/bower.json @@ -20,7 +20,7 @@ "purescript-effect": "^4.0.0", "purescript-either": "^6.0.0", "purescript-exceptions": "^6.0.0", - "purescript-node-buffer": "^8.0.0", + "purescript-node-buffer": "^9.0.0", "purescript-nullable": "^6.0.0", "purescript-prelude": "^6.0.0" } diff --git a/src/Node/Stream.purs b/src/Node/Stream.purs index 1f0c470..03eb611 100644 --- a/src/Node/Stream.purs +++ b/src/Node/Stream.purs @@ -95,7 +95,7 @@ onData r cb = where fromEither x = case x of - Left _ -> + Left _ -> throw "Stream encoding should not be set" Right buf -> pure buf @@ -103,13 +103,13 @@ onData r cb = read :: forall w . Readable w - -> Maybe Int - -> Effect (Maybe Buffer) + -> Maybe Int + -> Effect (Maybe Buffer) read r size = do v <- readEither r size case v of - Nothing -> pure Nothing - Just (Left _) -> throw "Stream encoding should not be set" + Nothing -> pure Nothing + Just (Left _) -> throw "Stream encoding should not be set" Just (Right b) -> pure (Just b) readString @@ -121,9 +121,9 @@ readString readString r size enc = do v <- readEither r size case v of - Nothing -> pure Nothing - Just (Left _) -> throw "Stream encoding should not be set" - Just (Right buf) -> Just <$> Buffer.toString enc buf + Nothing -> pure Nothing + Just (Left _) -> throw "Stream encoding should not be set" + Just (Right buf) -> Just <$> Buffer.toString enc buf readEither :: forall w diff --git a/test/Main.purs b/test/Main.purs index 9d9a520..b93662c 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -17,7 +17,6 @@ assertEqual :: forall a. Show a => Eq a => a -> a -> Effect Unit assertEqual x y = assert' (show x <> " did not equal " <> show y) (x == y) - foreign import writableStreamBuffer :: Effect (Writable ()) foreign import getContentsAsString :: forall r. Writable r -> Effect String @@ -58,34 +57,34 @@ testReads = do testReadBuf where - testReadString = do - sIn <- passThrough - v <- readString sIn Nothing UTF8 - assert (isNothing v) - - onReadable sIn do - str <- readString sIn Nothing UTF8 - assert (isJust str) - assertEqual (unsafePartial (fromJust str)) testString - pure unit - - writeString sIn UTF8 testString \_ -> do - pure unit - - testReadBuf = do - sIn <- passThrough - v <- read sIn Nothing - assert (isNothing v) - - onReadable sIn do - buf <- read sIn Nothing - assert (isJust buf) - _ <- assertEqual <$> (Buffer.toString UTF8 (unsafePartial (fromJust buf))) - <*> pure testString - pure unit - - writeString sIn UTF8 testString \_ -> do - pure unit + testReadString = do + sIn <- passThrough + v <- readString sIn Nothing UTF8 + assert (isNothing v) + + onReadable sIn do + str <- readString sIn Nothing UTF8 + assert (isJust str) + assertEqual (unsafePartial (fromJust str)) testString + pure unit + + writeString sIn UTF8 testString \_ -> do + pure unit + + testReadBuf = do + sIn <- passThrough + v <- read sIn Nothing + assert (isNothing v) + + onReadable sIn do + buf <- read sIn Nothing + assert (isJust buf) + _ <- assertEqual <$> (Buffer.toString UTF8 (unsafePartial (fromJust buf))) + <*> pure testString + pure unit + + writeString sIn UTF8 testString \_ -> do + pure unit testSetDefaultEncoding :: Effect Boolean testSetDefaultEncoding = do @@ -123,9 +122,9 @@ testSetEncoding = do testPipe :: Effect Boolean testPipe = do - sIn <- passThrough - sOut <- passThrough - zip <- createGzip + sIn <- passThrough + sOut <- passThrough + zip <- createGzip unzip <- createGunzip log "pipe 1" @@ -140,11 +139,9 @@ testPipe = do onDataString sOut UTF8 \str -> do assertEqual str testString - foreign import createGzip :: Effect Duplex foreign import createGunzip :: Effect Duplex - -- | Create a PassThrough stream, which simply writes its input to its output. foreign import passThrough :: Effect Duplex