forked from sonic-pi-net/sonic-pi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprune.rb
51 lines (41 loc) · 1.41 KB
/
prune.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/ruby -wU
#--
# This file is part of Sonic Pi: http://sonic-pi.net
# Full project source: https://github.com/samaaron/sonic-pi
# License: https://github.com/samaaron/sonic-pi/blob/main/LICENSE.md
#
# Copyright 2013, 2014, 2015, 2016 by Sam Aaron (http://sam.aaron.name).
# All rights reserved.
#
# Permission is granted for use, copying, modification, and
# distribution of modified versions of this work as long as this
# notice is included.
#++
require 'fileutils'
# Simple script to nuke all non lib dirs in the vendor tree. Useful for
# pruning an app pre release. Be very Careful as it will nuke everything
# recursively in a dir. Has a basic safety check (looks for
# app/server/vendor in the path) and by default doesn't do anything
# unless you change rehearse to false. Try not to nuke the wrong
# things!
# Call with:
# ./prune.rb path/to/vendor/dir
dir = ARGV[0]
rehearse = false
subdirs = Dir["#{dir}/*/*"].select{|d| File.directory?(d) && (File.basename(d) != "lib")}
puts dir
if !subdirs.empty?
raise "Aborting prune. Doesn't look like you're using an app/server/ruby/vendor dir" unless subdirs.first.match(/app\/server\/ruby\/vendor/)
if rehearse
puts "Would remove: "
puts subdirs
puts "Aborting prune operation. Turn rehearse off to remove files."
else
subdirs.each do |d|
puts "rm -rf #{d}"
FileUtils.rm_rf d
end
end
else
puts "Nothing to prune in #{dir}"
end