Skip to content

Commit aa0f4a6

Browse files
committed
Merge pull request #5 from joneshf/master
Added `exists`.
2 parents 3de6a7e + 1c5aad0 commit aa0f4a6

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@
123123

124124
chown :: forall eff. FilePath -> Number -> Number -> Eff (err :: Exception, fs :: FS | eff) Unit
125125

126+
exists :: forall eff. FilePath -> Eff (fs :: FS | eff) Boolean
127+
126128
link :: forall eff. FilePath -> FilePath -> Eff (err :: Exception, fs :: FS | eff) Unit
127129

128130
mkdir :: forall eff. FilePath -> Eff (err :: Exception, fs :: FS | eff) Unit

src/Node/FS/Sync.purs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module Node.FS.Sync
2121
, writeTextFile
2222
, appendFile
2323
, appendTextFile
24+
, exists
2425
) where
2526

2627
import Control.Monad.Eff
@@ -52,6 +53,7 @@ foreign import fs "var fs = require('fs');" ::
5253
, readFileSync :: forall a opts. Fn2 FilePath { | opts } a
5354
, writeFileSync :: forall a opts. Fn3 FilePath a { | opts } Unit
5455
, appendFileSync :: forall a opts. Fn3 FilePath a { | opts } Unit
56+
, existsSync :: Fn1 FilePath Boolean
5557
}
5658

5759
foreign import mkEff
@@ -278,3 +280,11 @@ appendTextFile :: forall eff. Encoding
278280

279281
appendTextFile encoding file buff = mkEff $ \_ -> runFn3
280282
fs.appendFileSync file buff { encoding: show encoding }
283+
284+
-- |
285+
-- Check if the path exists.
286+
--
287+
exists :: forall eff. FilePath
288+
-> Eff (fs :: FS | eff) Boolean
289+
exists file = mkEff $ \_ -> runFn1
290+
fs.existsSync file

0 commit comments

Comments
 (0)