Skip to content

Commit ec3f47d

Browse files
committed
Rmdir
1 parent f7b34b4 commit ec3f47d

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646

4747
rename :: forall eff. FilePath -> FilePath -> Callback eff Unit -> Eff (fs :: FS | eff) Unit
4848

49+
rmdir :: forall eff. FilePath -> Callback eff Unit -> Eff (fs :: FS | eff) Unit
50+
4951
stat :: forall eff. FilePath -> Callback eff Stats -> Eff (fs :: FS | eff) Unit
5052

5153
symlink :: forall eff. FilePath -> FilePath -> SymlinkType -> Callback eff Unit -> Eff (fs :: FS | eff) Unit
@@ -119,6 +121,8 @@
119121

120122
rename :: forall eff. FilePath -> FilePath -> Eff (err :: Exception Error, fs :: FS | eff) Unit
121123

124+
rmdir :: forall eff. FilePath -> Eff (err :: Exception Error, fs :: FS | eff) Unit
125+
122126
stat :: forall eff. FilePath -> Eff (err :: Exception Error, fs :: FS | eff) Stats
123127

124128
symlink :: forall eff. FilePath -> FilePath -> SymlinkType -> Eff (err :: Exception Error, fs :: FS | eff) Unit

src/Node/FS/Async.purs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module Node.FS.Async
1111
, realpath
1212
, realpath'
1313
, unlink
14+
, rmdir
1415
, readFile
1516
, readTextFile
1617
, writeFile
@@ -53,6 +54,7 @@ foreign import fs "var fs = require('fs');" ::
5354
, readlink :: Fn2 FilePath (JSCallback FilePath) Unit
5455
, realpath :: forall cache. Fn3 FilePath { | cache } (JSCallback FilePath) Unit
5556
, unlink :: Fn2 FilePath (JSCallback Unit) Unit
57+
, rmdir :: Fn2 FilePath (JSCallback Unit) Unit
5658
, readFile :: forall a opts. Fn3 FilePath { | opts } (JSCallback a) Unit
5759
, writeFile :: forall a opts. Fn4 FilePath a { | opts } (JSCallback Unit) Unit
5860
}
@@ -182,6 +184,16 @@ unlink :: forall eff. FilePath
182184
unlink file cb = return $ runFn2
183185
fs.unlink file (handleCallback cb)
184186

187+
-- |
188+
-- Deletes a directory.
189+
--
190+
rmdir :: forall eff. FilePath
191+
-> Callback eff Unit
192+
-> Eff (fs :: FS | eff) Unit
193+
194+
rmdir file cb = return $ runFn2
195+
fs.rmdir file (handleCallback cb)
196+
185197
-- |
186198
-- Reads the entire contents of a file returning the result as a raw buffer.
187199
--

src/Node/FS/Sync.purs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module Node.FS.Sync
1010
, realpath
1111
, realpath'
1212
, unlink
13+
, rmdir
1314
, readFile
1415
, readTextFile
1516
, writeFile
@@ -37,6 +38,7 @@ foreign import fs "var fs = require('fs');" ::
3738
, readlinkSync :: Fn1 FilePath FilePath
3839
, realpathSync :: forall cache. Fn2 FilePath { | cache } FilePath
3940
, unlinkSync :: Fn1 FilePath Unit
41+
, rmdirSync :: Fn1 FilePath Unit
4042
, readFileSync :: forall a opts. Fn2 FilePath { | opts } a
4143
, writeFileSync :: forall a opts. Fn3 FilePath a { | opts } Unit
4244
}
@@ -155,6 +157,15 @@ unlink :: forall eff. FilePath
155157
unlink file = mkEff $ \_ -> runFn1
156158
fs.unlinkSync file
157159

160+
-- |
161+
-- Deletes a directory.
162+
--
163+
rmdir :: forall eff. FilePath
164+
-> Eff (fs :: FS, err :: Exception Error | eff) Unit
165+
166+
rmdir file = mkEff $ \_ -> runFn1
167+
fs.rmdirSync file
168+
158169
-- |
159170
-- Reads the entire contents of a file returning the result as a raw buffer.
160171
--

0 commit comments

Comments
 (0)