Permalink
Browse files

Merge pull request #236 from jimbrowne/issue-205

Remove dirs empty due to --exclude.  Issue 205.
  • Loading branch information...
2 parents ad134e3 + 7d1d657 commit aaebf4b755ce7377d86a1916af360d38f65634aa @jordansissel committed Jul 22, 2012
Showing with 9 additions and 0 deletions.
  1. +9 −0 lib/fpm/package.rb
View
@@ -1,5 +1,6 @@
require "fpm/namespace" # local
require "fpm/util" # local
+require "pathname" # stdlib
require "tmpdir" # stdlib
require "backports" # gem 'backports'
require "socket" # stdlib, for Socket.gethostname
@@ -346,6 +347,14 @@ def exclude
if File.fnmatch(wildcard, file)
@logger.info("Removing excluded file", :path => file, :matches => wildcard)
FileUtils.remove_entry_secure(staging_path(file))
+ Pathname.new(staging_path(file)).parent.ascend do |d|
+ if (::Dir.entries(d) - %w[ . .. ]).empty?
+ ::Dir.rmdir(d)
+ @logger.info("Deleting empty directory left by removing exluded file", :path => d)
+ else
+ break
+ end
+ end
end
end
end

0 comments on commit aaebf4b

Please sign in to comment.