fs-vacuum
Remove the empty branches of a directory tree, optionally up to (but not including) a specified base directory. Optionally nukes the leaf directory.
Usage
var logger = ;var vacuum = ; var options = base : "/path/to/my/tree/root" purge : true log : loggersilly; /* Assuming there are no other files or directories in "out", "to", or "my", * the final path will just be "/path/to/my/tree/root". */;
vacuum(directory, options, callback)
directory
{String} Leaf node to remove. Must be a directory, symlink, or file.options
{Object}base
{String} No directories at or above this level of the filesystem will be removed.purge
{Boolean} If set, nuke the whole leaf directory, including its contents.log
{Function} A logging function that takesnpmlog
-compatible argument lists.
callback
{Function} Function to call once vacuuming is complete.error
{Error} What went wrong along the way, if anything.