Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tap-gen to cleanup empty directories #14

Open
thinkerbot opened this issue Jul 14, 2010 · 0 comments
Open

Update tap-gen to cleanup empty directories #14

thinkerbot opened this issue Jul 14, 2010 · 0 comments

Comments

@thinkerbot
Copy link
Owner

  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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant