From 73eeff557c0b6b3935075132cdf9c2f4e26faf69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20P=C3=A4tzel?= Date: Wed, 23 Oct 2024 15:57:00 +0200 Subject: [PATCH] Disable following links MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/JuliaFormatter.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JuliaFormatter.jl b/src/JuliaFormatter.jl index cd8da733..3cb8c3dd 100644 --- a/src/JuliaFormatter.jl +++ b/src/JuliaFormatter.jl @@ -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)