summaryrefslogtreecommitdiff
path: root/tool/lib
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2024-04-20 03:07:35 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2024-04-22 13:00:19 +0900
commitc65bc2e5d9f0bc56b22d6bb765a1f25c53aa2ea7 (patch)
tree642b2ba1c89bcddb378cbdfc3f4219d185c1f929 /tool/lib
parent9b6affa4a138a28578453ae41a96f3aafbd4d563 (diff)
Show left tmpdir recursively
Diffstat (limited to 'tool/lib')
-rw-r--r--tool/lib/_tmpdir.rb38
1 files changed, 22 insertions, 16 deletions
diff --git a/tool/lib/_tmpdir.rb b/tool/lib/_tmpdir.rb
index a238ea467e..f3b8560258 100644
--- a/tool/lib/_tmpdir.rb
+++ b/tool/lib/_tmpdir.rb
@@ -31,23 +31,29 @@ END {
filecolor = ->(st) {
st.directory? ? "bold;blue" : st.symlink? ? "bold;cyan" : st.executable? ? "bold;green" : nil
}
+ list_tree = ->(parent, indent = " ") {
+ Dir.children(parent).each do |child|
+ path = File.join(parent, child)
+ st = File.lstat(path)
+ m = st.mode
+ m = [
+ (st.file? ? ?- : st.ftype[0]),
+ mode_inspect[m >> 6, (?s unless m & 04000 == 0)],
+ mode_inspect[m >> 3, (?s unless m & 02000 == 0)],
+ mode_inspect[m, (?t unless m & 01000 == 0)],
+ ].join("")
+ warn [
+ indent, m, st.nlink, st.size, st.mtime,
+ colorize.decorate(child, filecolor[st]),
+ (["->", colorize.cyan(File.readlink(path))] if st.symlink?),
+ ].compact.join(" ")
+ if st.directory?
+ list_tree[File.join(parent, child), indent + " "]
+ end
+ end
+ }
warn colorize.notice("Children under ")+colorize.fail(tmpdir)+":"
- Dir.children(tmpdir).each do |child|
- path = File.join(tmpdir, child)
- st = File.lstat(path)
- m = st.mode
- m = [
- (st.file? ? ?- : st.ftype[0]),
- mode_inspect[m >> 6, (?s unless m & 04000 == 0)],
- mode_inspect[m >> 3, (?s unless m & 02000 == 0)],
- mode_inspect[m, (?t unless m & 01000 == 0)],
- ].join("")
- warn [
- " ", m, st.nlink, st.size, st.mtime,
- colorize.decorate(child, filecolor[st]),
- (["->", colorize.cyan(File.readlink(path))] if st.symlink?),
- ].compact.join(" ")
- end
+ list_tree[tmpdir]
FileUtils.rm_rf(tmpdir)
end
end