Skip to content

Commit

Permalink
Disable following links
Browse files Browse the repository at this point in the history
Following links resulted on my machine (running NixOS and using devenv)
in precompilation attempting to format read-only .jl files (because
`.devenv/profile` links to readonly `/nix/store/…` directories). Since I
don't see a case where you may want JuliaFormatter to jump to far-away
directory by following links (looks rather dangerous to me, actually?),
I simply disabled following links.

Note this could be improved by checking whether the link points to a
file within the currently-to-be-formatted directory.
  • Loading branch information
dpaetzel committed Oct 23, 2024
1 parent 2242a32 commit 73eeff5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/JuliaFormatter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ function format(path::AbstractString, options::Configuration)
formatted = Threads.Atomic{Bool}(true)
Threads.@threads for subpath in readdir(path)
subpath = joinpath(path, subpath)
if !ispath(subpath)
if !ispath(subpath) || islink(subpath)
continue
end
is_formatted = format(subpath, options)
Expand Down

0 comments on commit 73eeff5

Please sign in to comment.