@@ -13,6 +13,7 @@ module Node.FS.Async
1313 , unlink
1414 , rmdir
1515 , mkdir
16+ , mkdirRecursive
1617 , mkdir'
1718 , readdir
1819 , utimes
7576 , realpath :: forall cache . Fn3 FilePath { | cache } (JSCallback FilePath ) Unit
7677 , unlink :: Fn2 FilePath (JSCallback Unit ) Unit
7778 , rmdir :: Fn2 FilePath (JSCallback Unit ) Unit
78- , mkdir :: Fn3 FilePath String (JSCallback Unit ) Unit
79+ , mkdir :: Fn3 FilePath { recursive :: Boolean , mode :: String } (JSCallback Unit ) Unit
7980 , readdir :: Fn2 FilePath (JSCallback (Array FilePath )) Unit
8081 , utimes :: Fn4 FilePath Int Int (JSCallback Unit ) Unit
8182 , readFile :: forall a opts . Fn3 FilePath { | opts } (JSCallback a ) Unit
@@ -202,16 +203,33 @@ mkdir :: FilePath
202203 -> Callback Unit
203204 -> Effect Unit
204205
205- mkdir = flip mkdir' $ mkPerms all all all
206+ mkdir path = mkdir' path (mkPerms all all all)
207+
208+ -- | Makes a new directory and any directories that don't exist
209+ -- | in the path. Similar to `mkdir -p`.
210+ mkdirRecursive :: FilePath
211+ -> Callback Unit
212+ -> Effect Unit
213+
214+ mkdirRecursive path = mkdirRecursive' path (mkPerms all all all)
215+
216+ -- | Makes a new directory (and any directories that don't exist
217+ -- | in the path) with the specified permissions.
218+ mkdirRecursive'
219+ :: FilePath
220+ -> Perms
221+ -> Callback Unit
222+ -> Effect Unit
223+ mkdirRecursive' file perms cb = mkEffect $ \_ -> runFn3
224+ fs.mkdir file { recursive: true , mode: permsToString perms } (handleCallback cb)
206225
207226-- | Makes a new directory with the specified permissions.
208227mkdir' :: FilePath
209228 -> Perms
210229 -> Callback Unit
211230 -> Effect Unit
212-
213231mkdir' file perms cb = mkEffect $ \_ -> runFn3
214- fs.mkdir file ( permsToString perms) (handleCallback cb)
232+ fs.mkdir file { recursive: false , mode: permsToString perms } (handleCallback cb)
215233
216234-- | Reads the contents of a directory.
217235readdir :: FilePath
0 commit comments