def directory(target, options={})
target = path(target)
case
when !File.exists?(target)
log_relative :missing, target
when !File.directory?(target)
log_relative 'not a directory', target
when target == Dir.pwd
when !Root.empty?(target)
paths = Dir.glob File.join(target, '**/*')
paths.unshift(target)
paths.sort.reverse_each do |path|
if Root.empty?(path)
log_relative :rm, path
FileUtils.rmdir(path) unless pretend
else
log_relative('not empty', path)
end
end
else
log_relative :rm, target
FileUtils.rmdir(target) unless pretend
end
target
end