diff --git a/README.markdown b/README.markdown index 0c207aa..3805f7f 100644 --- a/README.markdown +++ b/README.markdown @@ -121,7 +121,9 @@ There are no `options` for this function. Remove a directory -There are no `options` for this function. +`options` can include: + + - options.recursive - (optional, default is `false`) whether to delete everything within this directory. `meta` in the response is empty. diff --git a/local/localfs.js b/local/localfs.js index ec839a1..beb2040 100644 --- a/local/localfs.js +++ b/local/localfs.js @@ -496,8 +496,24 @@ module.exports = function setup(fsOptions) { } function rmdir(path, options, callback) { - // TODO: add recursive delete to options? - remove(path, fs.rmdir, callback); + if (options.recursive) { + remove(path, function(path, callback) { + var rm = spawn("rm", ["-rf", path]); + var err = ""; + rm.on("stderr", function(data) { + err += data; + }); + rm.on("exit", function(code) { + if (code) { + return callback("error removing directory: " + code + " " + err.join("")); + } + callback(); + }); + }, callback); + } + else { + remove(path, fs.rmdir, callback); + } } function rmfile(path, options, callback) {