Skip to content

Commit

Permalink
Fix listfiles & add materialize
Browse files Browse the repository at this point in the history
  • Loading branch information
singularitti committed Feb 6, 2023
1 parent a8034f5 commit 58f7296
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/Files.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
export listfiles

using Configurations: @option
using FileTrees: FileTree, Path, files
using FileTrees: FileTree, mapsubtrees, path
using Glob: GlobMatch

@option struct ExpressFileTree
Expand All @@ -12,12 +12,19 @@ using Glob: GlobMatch
output_pattern::Union{String,Regex,GlobMatch}
end

function listfiles(patterns, root_dir=pwd())
tree = FileTree(root_dir)
return map((patterns.first, patterns.second)) do pattern
subtree = tree[pattern]
abspath.(Path.(files(subtree)))
function listfiles(patterns::Pair, root_dir=pwd())
tree = FileTree(expanduser(root_dir))
io = map(patterns) do pattern
files = String[]
mapsubtrees(tree, pattern) do subtree
push!(files, abspath(path(subtree)))
end
files
end
return Tuple(io)
end

materialize(config::ExpressFileTree) =
listfiles(config.input_pattern => config.output_pattern, config.root_dir)

# end

0 comments on commit 58f7296

Please sign in to comment.