Created
January 7, 2014 15:10
-
-
Save andrei512/8300691 to your computer and use it in GitHub Desktop.
This file contains 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
DERIVED_DATA_PATH = "~/Library/Developer/Xcode/DerivedData/" | |
def projects | |
`ls -al #{DERIVED_DATA_PATH}`.split("\n")[3..-1].map { |p| | |
ls_components = p.split(" ") | |
project_name = ls_components.last | |
if project_name != "ModuleCache" | |
project_name = project_name.split("-")[0..-2].join("-") | |
else | |
nil | |
end | |
}.select { |p| | |
p != nil | |
}.uniq | |
end | |
def remove_project_data project | |
did_remove_anything = false | |
`ls -al #{DERIVED_DATA_PATH}`.split("\n")[3..-1].each do |p| | |
ls_components = p.split(" ") | |
project_name = ls_components.last | |
if project_name[project] != nil | |
print "removing #{project_name}.." | |
`rm -rf #{DERIVED_DATA_PATH}#{project_name}` | |
did_remove_anything = true | |
print ".done\n" | |
end | |
end | |
unless did_remove_anything | |
puts "no derived data was asociated with #{project}" | |
end | |
end | |
def remove_all_data | |
projects.each do |project| | |
remove_project_data project | |
end | |
remove_project_data "ModuleCache" | |
end | |
if ARGV.count > 0 | |
ARGV.each do |project| | |
remove_project_data project | |
end | |
else | |
remove_all_data | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment