Skip to content

Remove deprecated exists #61

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
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Notable changes to this project are documented in this file. The format is based
## [Unreleased]

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

To get back the old behavior of `mkdir'`, you would call `mkdir' { recursive: false, mode: mkPerms all all all }`
Expand Down
1 change: 0 additions & 1 deletion src/Node/FS/Async.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export {
readFile as readFileImpl,
writeFile as writeFileImpl,
appendFile as appendFileImpl,
exists as existsImpl,
open as openImpl,
read as readImpl,
write as writeImpl,
Expand Down
9 changes: 0 additions & 9 deletions src/Node/FS/Async.purs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ module Node.FS.Async
, writeTextFile
, appendFile
, appendTextFile
, exists
, fdOpen
, fdRead
, fdNext
Expand All @@ -43,7 +42,6 @@ import Data.Nullable (Nullable, toNullable)
import Data.Time.Duration (Milliseconds(..))
import Effect (Effect)
import Effect.Exception (Error)
import Effect.Unsafe (unsafePerformEffect)
import Node.Buffer (Buffer, size)
import Node.Encoding (Encoding)
import Node.FS (FileDescriptor, ByteCount, FilePosition, BufferLength, BufferOffset, FileMode, FileFlags, SymlinkType, fileFlagsToNode, symlinkTypeToNode)
Expand Down Expand Up @@ -84,7 +82,6 @@ foreign import utimesImpl :: Fn4 FilePath Int Int (JSCallback Unit) Unit
foreign import readFileImpl :: forall a opts. Fn3 FilePath { | opts } (JSCallback a) Unit
foreign import writeFileImpl :: forall a opts. Fn4 FilePath a { | opts } (JSCallback Unit) Unit
foreign import appendFileImpl :: forall a opts. Fn4 FilePath a { | opts } (JSCallback Unit) Unit
foreign import existsImpl :: forall a. Fn2 FilePath (Boolean -> a) Unit
foreign import openImpl :: Fn4 FilePath String (Nullable FileMode) (JSCallback FileDescriptor) Unit
foreign import readImpl :: Fn6 FileDescriptor Buffer BufferOffset BufferLength (Nullable FilePosition) (JSCallback ByteCount) Unit
foreign import writeImpl :: Fn6 FileDescriptor Buffer BufferOffset BufferLength (Nullable FilePosition) (JSCallback ByteCount) Unit
Expand Down Expand Up @@ -291,12 +288,6 @@ appendTextFile :: Encoding
appendTextFile encoding file buff cb = mkEffect $ \_ -> runFn4
appendFileImpl file buff { encoding: show encoding } (handleCallback cb)

-- | Check if the path exists.
exists :: FilePath
-> (Boolean -> Effect Unit)
-> Effect Unit
exists file cb = mkEffect $ \_ -> runFn2
existsImpl file $ \b -> unsafePerformEffect (cb b)

-- | Open a file asynchronously. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_open_path_flags_mode_callback)
-- | for details.
Expand Down
21 changes: 9 additions & 12 deletions test/Test.purs
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
module Test where

import Prelude
import Data.Maybe (Maybe(..))

import Data.Either (Either(..), either)
import Data.Maybe (Maybe(..))
import Data.Traversable (traverse)
import Effect (Effect)
import Effect.Exception (Error, error, throwException, catchException)
import Effect.Console (log)

import Node.Encoding (Encoding(..))
import Effect.Exception (Error, error, throwException, catchException)
import Node.Buffer as Buffer
import Node.Path as Path
import Unsafe.Coerce (unsafeCoerce)

import Node.Encoding (Encoding(..))
import Node.FS (FileFlags(..))
import Node.FS.Stats (statusChangedTime, accessedTime, modifiedTime,
isSymbolicLink, isSocket, isFIFO, isCharacterDevice,
isBlockDevice, isDirectory, isFile)
import Node.FS.Async as A
import Node.FS.Stats (statusChangedTime, accessedTime, modifiedTime, isSymbolicLink, isSocket, isFIFO, isCharacterDevice, isBlockDevice, isDirectory, isFile)
import Node.FS.Sync as S
import Node.Path as Path
import Unsafe.Coerce (unsafeCoerce)

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

A.exists (fp ["test", "Test.purs"]) $ \e ->
log $ "Test.purs exists? " <> show e
e <- S.exists (fp ["test", "Test.purs"])
log $ "Test.purs exists? " <> show e

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