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

Add XDG Base Directory Specification support #7386

Merged
merged 3 commits into from Mar 3, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion Sources/Basics/FileSystem/FileSystem+Extensions.swift
Expand Up @@ -12,6 +12,7 @@

import struct Foundation.Data
import class Foundation.FileManager
import class Foundation.ProcessInfo
MaxDesiatov marked this conversation as resolved.
Show resolved Hide resolved
import struct Foundation.UUID
import SystemPackage

Expand Down Expand Up @@ -211,9 +212,14 @@ extension FileSystem {

extension FileSystem {
/// SwiftPM directory under user's home directory (~/.swiftpm)
/// or under $XDG_CONFIG_HOME/swiftpm if the environmental variable is defined
public var dotSwiftPM: AbsolutePath {
get throws {
try self.homeDirectory.appending(".swiftpm")
if let configurationDirectory = EnvironmentVariables.process()["XDG_CONFIG_HOME"] {
return try AbsolutePath(validating: configurationDirectory).appending("swiftpm")
} else {
return try self.homeDirectory.appending(".swiftpm")
}
}
}

Expand Down