Skip to content

Instantly share code, notes, and snippets.

@sandeeplearner
Last active August 17, 2020 22:02
Show Gist options
  • Save sandeeplearner/fefb1d6771db04679a8aaaef3a3b4091 to your computer and use it in GitHub Desktop.
Save sandeeplearner/fefb1d6771db04679a8aaaef3a3b4091 to your computer and use it in GitHub Desktop.
Delete existing group
#!/usr/bin/ruby
def find_proto_group(parentGroup)
puts "Number of groups in parent is #{parentGroup.groups.count()}"
if parentGroup.groups.count() > 0
parentGroup.groups.each do |group|
if group.name == @proto_group_name
delete_group_and_files(group)
return
end
end
end
copy_files_to_folder(parentGroup)
end
def delete_group_and_files(proto_group)
mainGroup = proto_group.parent
groupPath = proto_group.real_path
proto_group.clear()
proto_group.remove_from_project()
if Dir.exist?(groupPath)
puts "Deleting folder using rm_rf"
FileUtils.rm_rf("#{groupPath}/.", secure: true)
Dir.delete(groupPath)
else
proto_group.children.each do |items|
File.delete("#{groupPath}/#{items.path}")
end
end
copy_files_to_folder(mainGroup)
end
def copy_files_to_folder(group)
puts "Current directory is #{group.path} and real path is #{group.real_path}"
FileUtils.cp_r(File.join(Dir.home, "Documents", "GitClone", "SwiftProtoFiles"), group.real_path)
if Dir.exists?(File.join(group.real_path, @proto_group_name))
add_group_to_project(group, @proto_group_name, @project)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment