Skip to content

Commit 3890dc6

Browse files
authored
Remove deprecated exists (#61)
* Remove deprecated exists * Update changelog * Remove redundant import
1 parent a869ea6 commit 3890dc6

File tree

4 files changed

+10
-22
lines changed

4 files changed

+10
-22
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Notable changes to this project are documented in this file. The format is based
55
## [Unreleased]
66

77
Breaking changes:
8+
- Remove `Async.exists` (#61 by @sigma-andex)
89
- Update `mkdir` to take an options record arg, exposing `recursive` option (#53, #55, #58 by @JordanMartinez)
910

1011
To get back the old behavior of `mkdir'`, you would call `mkdir' { recursive: false, mode: mkPerms all all all }`

src/Node/FS/Async.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export {
1616
readFile as readFileImpl,
1717
writeFile as writeFileImpl,
1818
appendFile as appendFileImpl,
19-
exists as existsImpl,
2019
open as openImpl,
2120
read as readImpl,
2221
write as writeImpl,

src/Node/FS/Async.purs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ module Node.FS.Async
2222
, writeTextFile
2323
, appendFile
2424
, appendTextFile
25-
, exists
2625
, fdOpen
2726
, fdRead
2827
, fdNext
@@ -43,7 +42,6 @@ import Data.Nullable (Nullable, toNullable)
4342
import Data.Time.Duration (Milliseconds(..))
4443
import Effect (Effect)
4544
import Effect.Exception (Error)
46-
import Effect.Unsafe (unsafePerformEffect)
4745
import Node.Buffer (Buffer, size)
4846
import Node.Encoding (Encoding)
4947
import Node.FS (FileDescriptor, ByteCount, FilePosition, BufferLength, BufferOffset, FileMode, FileFlags, SymlinkType, fileFlagsToNode, symlinkTypeToNode)
@@ -84,7 +82,6 @@ foreign import utimesImpl :: Fn4 FilePath Int Int (JSCallback Unit) Unit
8482
foreign import readFileImpl :: forall a opts. Fn3 FilePath { | opts } (JSCallback a) Unit
8583
foreign import writeFileImpl :: forall a opts. Fn4 FilePath a { | opts } (JSCallback Unit) Unit
8684
foreign import appendFileImpl :: forall a opts. Fn4 FilePath a { | opts } (JSCallback Unit) Unit
87-
foreign import existsImpl :: forall a. Fn2 FilePath (Boolean -> a) Unit
8885
foreign import openImpl :: Fn4 FilePath String (Nullable FileMode) (JSCallback FileDescriptor) Unit
8986
foreign import readImpl :: Fn6 FileDescriptor Buffer BufferOffset BufferLength (Nullable FilePosition) (JSCallback ByteCount) Unit
9087
foreign import writeImpl :: Fn6 FileDescriptor Buffer BufferOffset BufferLength (Nullable FilePosition) (JSCallback ByteCount) Unit
@@ -291,12 +288,6 @@ appendTextFile :: Encoding
291288
appendTextFile encoding file buff cb = mkEffect $ \_ -> runFn4
292289
appendFileImpl file buff { encoding: show encoding } (handleCallback cb)
293290

294-
-- | Check if the path exists.
295-
exists :: FilePath
296-
-> (Boolean -> Effect Unit)
297-
-> Effect Unit
298-
exists file cb = mkEffect $ \_ -> runFn2
299-
existsImpl file $ \b -> unsafePerformEffect (cb b)
300291

301292
-- | Open a file asynchronously. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_open_path_flags_mode_callback)
302293
-- | for details.

test/Test.purs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
module Test where
22

33
import Prelude
4-
import Data.Maybe (Maybe(..))
4+
55
import Data.Either (Either(..), either)
6+
import Data.Maybe (Maybe(..))
67
import Data.Traversable (traverse)
78
import Effect (Effect)
8-
import Effect.Exception (Error, error, throwException, catchException)
99
import Effect.Console (log)
10-
11-
import Node.Encoding (Encoding(..))
10+
import Effect.Exception (Error, error, throwException, catchException)
1211
import Node.Buffer as Buffer
13-
import Node.Path as Path
14-
import Unsafe.Coerce (unsafeCoerce)
15-
12+
import Node.Encoding (Encoding(..))
1613
import Node.FS (FileFlags(..))
17-
import Node.FS.Stats (statusChangedTime, accessedTime, modifiedTime,
18-
isSymbolicLink, isSocket, isFIFO, isCharacterDevice,
19-
isBlockDevice, isDirectory, isFile)
2014
import Node.FS.Async as A
15+
import Node.FS.Stats (statusChangedTime, accessedTime, modifiedTime, isSymbolicLink, isSocket, isFIFO, isCharacterDevice, isBlockDevice, isDirectory, isFile)
2116
import Node.FS.Sync as S
17+
import Node.Path as Path
18+
import Unsafe.Coerce (unsafeCoerce)
2219

2320
-- Cheat to allow `main` to type check. See also issue #5 in
2421
-- purescript-exceptions.
@@ -34,8 +31,8 @@ main :: Effect Unit
3431
main = do
3532
let fp = Path.concat
3633

37-
A.exists (fp ["test", "Test.purs"]) $ \e ->
38-
log $ "Test.purs exists? " <> show e
34+
e <- S.exists (fp ["test", "Test.purs"])
35+
log $ "Test.purs exists? " <> show e
3936

4037
file <- S.readTextFile UTF8 (fp ["test", "Test.purs"])
4138
log "\n\nreadTextFile sync result:"

0 commit comments

Comments
 (0)