Method: DiscourseTheme::Uploader#compress_dir
- Defined in:
- lib/discourse_theme/uploader.rb
#compress_dir(gzip, dir) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/discourse_theme/uploader.rb', line 11 def compress_dir(gzip, dir) sgz = Zlib::GzipWriter.new(File.open(gzip, "wb")) tar = Archive::Tar::Minitar::Output.new(sgz) Dir.chdir(dir + "/../") do Find.find(File.basename(dir)) do |x| bn = File.basename(x) Find.prune if bn == "node_modules" || bn == "src" || bn[0] == "." next if File.directory?(x) Minitar.pack_file(x, tar) end end ensure tar.close sgz.close end |