Skip to content

Commit

Permalink
Disable following links (#884)
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 authored Oct 24, 2024
1 parent 2242a32 commit 474673e
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 474673e

Please sign in to comment.