Remove Files
Path:
/src/method/remove.coffeecompiled to/lib/method/remove.js
This method will remove the given path entry and if it is a directory it
will also remove any containing data or only the selection of files.
The option maxdepth is only supported in the search, but if a directory is
matched everything within will be deleted.
This method will remove the given path entry and if it is a directory it
will also remove any containing data. If some filter given you can also delete#
selectively.
To select which files to remove the following options may be used:
filter-Array<Object>|ObjectFilter Rulesdereference-Booleandereference symbolic links and go into themìgnoreErrors-Booleango on and ignore IO errorsparallel-Integernumber of maximum parallel calls in asynchronous run (defaults to half of open files limit per process on the system)
Example:
CoffeeScript Code fs = require 'alinex-fs'
fs.remove '/tmp/some/directory', (err, removed) ->
return console.error err if err
if removed
console.log "Directory '"+removed+"' was removed with all it's contents."
console.log "Directory no longer exists!"
remove()
Usage:
remove(source, options, cb)
- Parameter
-
source-Stringdirectory or file to be deletedoptions-Objectoptional specifications for check defining which files to removecb-function(Error, Array<String>)optional callback which is called after done with possibleÈrroror with the files/directories been deleted
removeSync()
Usage:
removeSync(path, options)
- Parameter
-
path-Stringdirectory or file to be deletedoptions-Objectoptional specifications for check defining which files to remove
- Return
Array<String>the files or directories been deleted- Throws
-
Errorif domething went wrong
Debugging
This module uses thedebug module so you may anytime call your app with
the environment setting DEBUG=fs:remove for the output of this method only.
Because there are mkdirs subcalls here you see the output of DEBUG=fs:* while
removeing a small directory:
fs:remove check test/temp/dir1 +29ms
fs:filter skip test/temp/dir1 because not in specified depth +1ms
fs:remove going deeper into test/temp/dir1 directory +0ms
fs:remove check test/temp/dir1/file11 +0ms
fs:remove removing test/temp/dir1/file11 (file) +0ms