bin/xcodert in xcode_trash_remover-1.0.0 vs bin/xcodert in xcode_trash_remover-1.0.1

- old
+ new

@@ -1,43 +1,10 @@ #!/usr/bin/env ruby -require 'fileutils' -require 'find' +require 'xcode_trash_remover' -module XcodeDirectories - DERIVED_DATA = "#{File.expand_path('~')}/Library/Developer/Xcode/DerivedData/*" - ARCHIVES = "#{File.expand_path('~')}/Library/Developer/Xcode/Archives/*" -end - -def dir_size(dir_path) - total_size = 0 - Find.find(dir_path) do |path| - if FileTest.directory?(path) - if File.basename(path)[0] == ?. - Find.prune - else - next - end - else - total_size += FileTest.size(path) - end - end - total_size -end - -trash_size = 0 -XcodeDirectories.constants.each do |dir| - files = Dir.glob(XcodeDirectories.const_get(dir)) - if files.empty? - next - end - files.each do |folder| - trash_size += dir_size(folder) - FileUtils.rm_rf(folder) - end -end - +trash_size = XcodeTrashRemover::Core.get_trash_size if trash_size > 0 - puts "Deleted all files from #{XcodeDirectories.constants[0]} and #{XcodeDirectories.constants[1]}" - puts "\n#{trash_size} bytes deleted" + XcodeTrashRemover::Core.remove_trash + puts "#{trash_size} bytes deleted" else - puts "The directories are empty" + puts "The directories are empty. No trash files." end