Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recursively looking for files in newFileTable #42

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions nimutils/filetable.nim
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ proc staticListFiles*(arg: string): seq[string] =
result = @[]

let
lines = staticExec("ls --color=never -pF " & arg &
" | grep -v \"[^a-zA-Z0-9]$\"")
lines = staticExec("find " & arg & " -type f " &
" | grep -v \"[^a-zA-Z0-9]$\"")
items = split(lines, "\n")

for item in items:
result.add(item.strip())
var path = item
path.removePrefix(arg)
path.removePrefix(DirSep)
result.add(path.strip())


template newFileTable*(dir: static[string]): FileTable =
Expand All @@ -55,7 +58,7 @@ template newFileTable*(dir: static[string]): FileTable =
let
pathToFile = pwd.joinPath(filename)
fileContents = staticRead(pathToFile)
key = splitFile(filename).name
key = splitFile(filename).name.toLower()

ret[key] = fileContents
ret
Expand Down
Loading