Skip to content

Commit

Permalink
Merge pull request #236 from jimbrowne/issue-205
Browse files Browse the repository at this point in the history
Remove dirs empty due to --exclude.  Issue 205.
  • Loading branch information
jordansissel committed Jul 22, 2012
2 parents ad134e3 + 7d1d657 commit aaebf4b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/fpm/package.rb
@@ -1,5 +1,6 @@
require "fpm/namespace" # local require "fpm/namespace" # local
require "fpm/util" # local require "fpm/util" # local
require "pathname" # stdlib
require "tmpdir" # stdlib require "tmpdir" # stdlib
require "backports" # gem 'backports' require "backports" # gem 'backports'
require "socket" # stdlib, for Socket.gethostname require "socket" # stdlib, for Socket.gethostname
Expand Down Expand Up @@ -346,6 +347,14 @@ def exclude
if File.fnmatch(wildcard, file) if File.fnmatch(wildcard, file)
@logger.info("Removing excluded file", :path => file, :matches => wildcard) @logger.info("Removing excluded file", :path => file, :matches => wildcard)
FileUtils.remove_entry_secure(staging_path(file)) 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 end
end end
Expand Down

0 comments on commit aaebf4b

Please sign in to comment.