Created
July 25, 2019 22:49
-
-
Save hsbt/71acec37139fab53b93abbb1c3a06b36 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "find" | |
require "pathname" | |
require "parallel" | |
RB_EXT_NAMES = %w[.rb .ru .gemspec .rake .cmd .gemfile .thor] | |
C_EXT_NAMES = %w[.c .h .cpp .hpp] | |
Parallel.map(Dir.glob("latest-gem/*").shuffle) do |dir| | |
Find.find(dir) {|fn| | |
st = File.lstat(fn) | |
if st.file? | |
if C_EXT_NAMES.any?{|ext| fn.end_with?(ext)} | |
next | |
elsif !(RB_EXT_NAMES.any?{|ext| fn.end_with?(ext)} || Pathname(fn).extname.empty?) || | |
fn =~ /vendor\/bundle/ || fn =~ /vendor\/ruby\// || fn =~ /bundle\/ruby/ | |
File.unlink fn | |
puts "removed: #{fn}" | |
next | |
end | |
end | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment