Skip to content

Commit c133563

Browse files
committed
Factor dir-tree-node out of Dir.children and export
1 parent c6b056d commit c133563

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lib/Terminal/Widgets/Volatile/DirTree.rakumod

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,18 @@ class Dir does Parent {
5454
# Directory read may fail due to insufficient permissions
5555
try my @entries = $!path.dir;
5656

57-
@!children = @entries.map: {
58-
.d ?? Dir.new( parent => self, path => $_) !!
59-
.l ?? SymLink.new(parent => self, path => $_, target => .readlink) !!
60-
.f ?? File.new( parent => self, path => $_) !!
61-
.dev ?? Dev.new( parent => self, path => $_) !!
62-
Misc.new( parent => self, path => $_) ;
63-
};
57+
@!children = @entries.map({ dir-tree-node($_, parent => self) });
6458
}
6559
@!children
6660
}
6761
}
62+
63+
sub dir-tree-node(IO::Path:D() $path, Node :$parent) is export {
64+
with $path {
65+
.d ?? Dir.new( :$parent, path => $_) !!
66+
.l ?? SymLink.new(:$parent, path => $_, target => .readlink) !!
67+
.f ?? File.new( :$parent, path => $_) !!
68+
.dev ?? Dev.new( :$parent, path => $_) !!
69+
Misc.new( :$parent, path => $_) ;
70+
}
71+
}

0 commit comments

Comments
 (0)