Skip to content
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
config loading cleaned
  • Loading branch information
WuerfelDev committed Nov 13, 2024
commit 9d598bd44bd264578631423950e152058619038c
20 changes: 10 additions & 10 deletions Sources/swift-format/Frontend/Frontend.swift
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,14 @@ class Frontend {
configLocations.append(URL(fileURLWithPath: xdgConfigHome))
}

if let libraryUrl = FileManager.default.urls(
for: .applicationSupportDirectory, in: .userDomainMask
).first {
configLocations.append(libraryUrl)
if let homeLocation = ProcessInfo.processInfo.environment["HOME"] {
configLocations.append(URL(fileURLWithPath: homeLocation + "/.config/"))
}

for supportDirectoryUrl in FileManager.default.urls(
for: .applicationSupportDirectory, in: .userDomainMask)
{
configLocations.append(supportDirectoryUrl)
}

if let xdgConfigDirs = ProcessInfo.processInfo.environment["XDG_CONFIG_DIRS"] {
Expand All @@ -279,12 +283,8 @@ class Frontend {
#endif

for case var location? in configLocations {
if #available(macOS 13.0, iOS 16.0, *) {
location.append(components: "swift-format", "config.json")
} else {
location.appendPathComponent("swift-format", isDirectory: true)
location.appendPathComponent("config.json", isDirectory: false)
}
location.appendPathComponent("swift-format", isDirectory: true)
location.appendPathComponent("config.json", isDirectory: false)
if FileManager.default.fileExists(atPath: location.path) {
do {
let configuration = try configurationLoader.configuration(at: location)
Expand Down