diff --git a/README.md b/README.md index a635ae0..c65b9e9 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ -## Module Node.FS.Aff +## Node.FS.Aff -[Node.FS][Node.FS] Wrappers for [purescript-aff][aff] +> [Node.FS][Node.FS] Wrappers for [purescript-aff][aff] The `Aff` monad let's you write async code with ease. +#### Example + Consider asynchronously listing only non-hidden directories: ``` purescript @@ -18,242 +20,13 @@ main = launchAff do liftEff $ print files' ``` -That was easy. For a working example, see [example.purs][example]. -To build the example, run `gulp example`. - -[Node.FS]: http://github.com/purescript-node/purescript-node-fs -[aff]: https://github.com/slamdata/purescript-aff -[example]: http://github.com/purescript-node/purescript-node-fs-aff/blob/master/example/example.purs - -#### `rename` - -``` purescript -rename :: forall eff. FilePath -> FilePath -> Aff (fs :: FS | eff) Unit -``` - - -Rename a file. - - -#### `truncate` - -``` purescript -truncate :: forall eff. FilePath -> Number -> Aff (fs :: FS | eff) Unit -``` - - -Truncates a file to the specified length. - - -#### `chown` - -``` purescript -chown :: forall eff. FilePath -> Number -> Number -> Aff (fs :: FS | eff) Unit -``` - - -Changes the ownership of a file. - - -#### `chmod` - -``` purescript -chmod :: forall eff. FilePath -> Perms -> Aff (fs :: FS | eff) Unit -``` - - -Changes the permissions of a file. - +That was easy. Run `gulp example` to see it work. -#### `stat` - -``` purescript -stat :: forall eff. FilePath -> Aff (fs :: FS | eff) Stats -``` - - -Gets file statistics. - - -#### `link` - -``` purescript -link :: forall eff. FilePath -> FilePath -> Aff (fs :: FS | eff) Unit -``` - - -Creates a link to an existing file. - - -#### `symlink` - -``` purescript -symlink :: forall eff. FilePath -> FilePath -> SymlinkType -> Aff (fs :: FS | eff) Unit -``` - - -Creates a symlink. - - -#### `readlink` - -``` purescript -readlink :: forall eff. FilePath -> Aff (fs :: FS | eff) FilePath -``` - - -Reads the value of a symlink. - - -#### `realpath` - -``` purescript -realpath :: forall eff. FilePath -> Aff (fs :: FS | eff) FilePath -``` - - -Find the canonicalized absolute location for a path. - - -#### `realpath'` - -``` purescript -realpath' :: forall eff cache. FilePath -> { | cache } -> Aff (fs :: FS | eff) FilePath -``` - - -Find the canonicalized absolute location for a path using a cache object -for already resolved paths. - - -#### `unlink` - -``` purescript -unlink :: forall eff. FilePath -> Aff (fs :: FS | eff) Unit -``` - - -Deletes a file. - - -#### `rmdir` - -``` purescript -rmdir :: forall eff. FilePath -> Aff (fs :: FS | eff) Unit -``` - - -Deletes a directory. - - -#### `mkdir` - -``` purescript -mkdir :: forall eff. FilePath -> Aff (fs :: FS | eff) Unit -``` - - -Makes a new directory. - - -#### `mkdir'` - -``` purescript -mkdir' :: forall eff. FilePath -> Perms -> Aff (fs :: FS | eff) Unit -``` - - -Makes a new directory with the specified permissions. - - -#### `readdir` - -``` purescript -readdir :: forall eff. FilePath -> Aff (fs :: FS | eff) (Array FilePath) -``` - - -Reads the contents of a directory. - - -#### `utimes` - -``` purescript -utimes :: forall eff. FilePath -> Date -> Date -> Aff (fs :: FS | eff) Unit -``` - - -Sets the accessed and modified times for the specified file. - - -#### `readFile` - -``` purescript -readFile :: forall eff. FilePath -> Aff (fs :: FS | eff) Buffer -``` - - -Reads the entire contents of a file returning the result as a raw buffer. - - -#### `readTextFile` - -``` purescript -readTextFile :: forall eff. Encoding -> FilePath -> Aff (fs :: FS | eff) String -``` - - -Reads the entire contents of a text file with the specified encoding. - - -#### `writeFile` - -``` purescript -writeFile :: forall eff. FilePath -> Buffer -> Aff (fs :: FS | eff) Unit -``` - - -Writes a buffer to a file. - - -#### `writeTextFile` - -``` purescript -writeTextFile :: forall eff. Encoding -> FilePath -> String -> Aff (fs :: FS | eff) Unit -``` - - -Writes text to a file using the specified encoding. - - -#### `appendFile` - -``` purescript -appendFile :: forall eff. FilePath -> Buffer -> Aff (fs :: FS | eff) Unit -``` - - -Appends the contents of a buffer to a file. - - -#### `appendTextFile` - -``` purescript -appendTextFile :: forall eff. Encoding -> FilePath -> String -> Aff (fs :: FS | eff) Unit -``` - - -Appends text to a file using the specified encoding. - - -#### `exists` - -``` purescript -exists :: forall eff. String -> Aff (fs :: FS | eff) Boolean -``` - - -Check to see if a file exists. +#### Documentation +[Read the module docs][docs] +[Node.FS]: http://github.com/purescript-node/purescript-node-fs +[aff]: https://github.com/slamdata/purescript-aff +[docs]: http://github.com/purescript-node/purescript-node-fs-aff/blob/master/docs/Node/FS/Aff.md diff --git a/docs/Node/FS/Aff.md b/docs/Node/FS/Aff.md new file mode 100644 index 0000000..fc8e095 --- /dev/null +++ b/docs/Node/FS/Aff.md @@ -0,0 +1,234 @@ +## Module Node.FS.Aff + +#### `rename` + +``` purescript +rename :: forall eff. FilePath -> FilePath -> Aff (fs :: FS | eff) Unit +``` + + +Rename a file. + + +#### `truncate` + +``` purescript +truncate :: forall eff. FilePath -> Number -> Aff (fs :: FS | eff) Unit +``` + + +Truncates a file to the specified length. + + +#### `chown` + +``` purescript +chown :: forall eff. FilePath -> Number -> Number -> Aff (fs :: FS | eff) Unit +``` + + +Changes the ownership of a file. + + +#### `chmod` + +``` purescript +chmod :: forall eff. FilePath -> Perms -> Aff (fs :: FS | eff) Unit +``` + + +Changes the permissions of a file. + + +#### `stat` + +``` purescript +stat :: forall eff. FilePath -> Aff (fs :: FS | eff) Stats +``` + + +Gets file statistics. + + +#### `link` + +``` purescript +link :: forall eff. FilePath -> FilePath -> Aff (fs :: FS | eff) Unit +``` + + +Creates a link to an existing file. + + +#### `symlink` + +``` purescript +symlink :: forall eff. FilePath -> FilePath -> SymlinkType -> Aff (fs :: FS | eff) Unit +``` + + +Creates a symlink. + + +#### `readlink` + +``` purescript +readlink :: forall eff. FilePath -> Aff (fs :: FS | eff) FilePath +``` + + +Reads the value of a symlink. + + +#### `realpath` + +``` purescript +realpath :: forall eff. FilePath -> Aff (fs :: FS | eff) FilePath +``` + + +Find the canonicalized absolute location for a path. + + +#### `realpath'` + +``` purescript +realpath' :: forall eff cache. FilePath -> { | cache } -> Aff (fs :: FS | eff) FilePath +``` + + +Find the canonicalized absolute location for a path using a cache object +for already resolved paths. + + +#### `unlink` + +``` purescript +unlink :: forall eff. FilePath -> Aff (fs :: FS | eff) Unit +``` + + +Deletes a file. + + +#### `rmdir` + +``` purescript +rmdir :: forall eff. FilePath -> Aff (fs :: FS | eff) Unit +``` + + +Deletes a directory. + + +#### `mkdir` + +``` purescript +mkdir :: forall eff. FilePath -> Aff (fs :: FS | eff) Unit +``` + + +Makes a new directory. + + +#### `mkdir'` + +``` purescript +mkdir' :: forall eff. FilePath -> Perms -> Aff (fs :: FS | eff) Unit +``` + + +Makes a new directory with the specified permissions. + + +#### `readdir` + +``` purescript +readdir :: forall eff. FilePath -> Aff (fs :: FS | eff) (Array FilePath) +``` + + +Reads the contents of a directory. + + +#### `utimes` + +``` purescript +utimes :: forall eff. FilePath -> Date -> Date -> Aff (fs :: FS | eff) Unit +``` + + +Sets the accessed and modified times for the specified file. + + +#### `readFile` + +``` purescript +readFile :: forall eff. FilePath -> Aff (fs :: FS | eff) Buffer +``` + + +Reads the entire contents of a file returning the result as a raw buffer. + + +#### `readTextFile` + +``` purescript +readTextFile :: forall eff. Encoding -> FilePath -> Aff (fs :: FS | eff) String +``` + + +Reads the entire contents of a text file with the specified encoding. + + +#### `writeFile` + +``` purescript +writeFile :: forall eff. FilePath -> Buffer -> Aff (fs :: FS | eff) Unit +``` + + +Writes a buffer to a file. + + +#### `writeTextFile` + +``` purescript +writeTextFile :: forall eff. Encoding -> FilePath -> String -> Aff (fs :: FS | eff) Unit +``` + + +Writes text to a file using the specified encoding. + + +#### `appendFile` + +``` purescript +appendFile :: forall eff. FilePath -> Buffer -> Aff (fs :: FS | eff) Unit +``` + + +Appends the contents of a buffer to a file. + + +#### `appendTextFile` + +``` purescript +appendTextFile :: forall eff. Encoding -> FilePath -> String -> Aff (fs :: FS | eff) Unit +``` + + +Appends text to a file using the specified encoding. + + +#### `exists` + +``` purescript +exists :: forall eff. String -> Aff (fs :: FS | eff) Boolean +``` + + +Check to see if a file exists. + + + diff --git a/gulpfile.js b/gulpfile.js index 5369b68..ac474c7 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -25,7 +25,7 @@ gulp.task('psci', function() { gulp.task('docs', function () { return purs.pscDocs({ src: src - , docgen: { 'Node.FS.Aff': 'README.md' } + , docgen: { 'Node.FS.Aff': 'docs/Node/FS/Aff.md' } }); }); diff --git a/src/Node/FS/Aff.purs b/src/Node/FS/Aff.purs index e958f35..bb2d9aa 100644 --- a/src/Node/FS/Aff.purs +++ b/src/Node/FS/Aff.purs @@ -1,28 +1,3 @@ --- | --- | [Node.FS][Node.FS] Wrappers for [purescript-aff][aff] --- | --- | The `Aff` monad let's you write async code with ease. --- | --- | Consider asynchronously listing only non-hidden directories: --- | --- | ``` purescript --- | main = launchAff do --- | files <- FS.readdir "." --- | files' <- flip filterM files \file -> do --- | stat <- FS.stat file --- | return $ --- | FS.isDirectory stat --- | && (maybe false (fromChar >>> (/= ".")) $ charAt 0 file) --- | liftEff $ print files' --- | ``` --- | --- | That was easy. For a working example, see [example.purs][example]. --- | To build the example, run `gulp example`. --- | --- | [Node.FS]: http://github.com/purescript-node/purescript-node-fs --- | [aff]: https://github.com/slamdata/purescript-aff --- | [example]: http://github.com/purescript-node/purescript-node-fs-aff/blob/master/example/example.purs - module Node.FS.Aff ( rename , truncate