Remove dirs empty due to --exclude. Issue 205.

This commit is contained in:
Jim Browne 2012-06-28 16:46:05 -07:00
parent 1768a45905
commit 8202756e7b
1 changed files with 7 additions and 0 deletions

View File

@ -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,12 @@ class FPM::Package
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)
end
end
end
end
end