Skip to content

Commit 2ba88d3

Browse files
committed
be more noisy
1 parent 2e8f76f commit 2ba88d3

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

Sources/Basics/FileSystem+Extensions.swift

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,14 @@ extension FileSystem {
100100
// but leave them there for backwards compatibility (eg older xcode)
101101
let oldConfigDirectory = idiomaticConfigurationDirectory.parentDirectory
102102
if self.exists(oldConfigDirectory, followSymlink: false) && self.isDirectory(oldConfigDirectory) {
103-
let content = try self.getDirectoryContents(oldConfigDirectory).filter{ !$0.hasSuffix(".lock") }
104-
for item in content {
105-
if self.isFile(oldConfigDirectory.appending(component: item)) &&
106-
!self.isSymlink(oldConfigDirectory.appending(component: item)) &&
107-
!self.exists(idiomaticConfigurationDirectory.appending(component: item)) {
108-
observabilityScope?.emit(warning: "Usage of \(oldConfigDirectory.appending(component: item)) has been deprecated. Please delete it and use the new \(idiomaticConfigurationDirectory.appending(component: item)) instead.")
109-
try self.copy(from: oldConfigDirectory.appending(component: item), to: idiomaticConfigurationDirectory.appending(component: item))
103+
let configurationFiles = try self.getDirectoryContents(oldConfigDirectory)
104+
.map{ oldConfigDirectory.appending(component: $0) }
105+
.filter{ self.isFile($0) && !self.isSymlink($0) && $0.extension != "lock"}
106+
for file in configurationFiles {
107+
let destination = idiomaticConfigurationDirectory.appending(component: file.basename)
108+
observabilityScope?.emit(warning: "Usage of \(file) has been deprecated. Please delete it and use the new \(destination) instead.")
109+
if !self.exists(destination) {
110+
try self.copy(from: file, to: destination)
110111
}
111112
}
112113
}
@@ -116,13 +117,14 @@ extension FileSystem {
116117
// but leave them there for backwards compatibility (eg older toolchain)
117118
let oldConfigDirectory = self.dotSwiftPM.appending(component: "config")
118119
if self.exists(oldConfigDirectory, followSymlink: false) && self.isDirectory(oldConfigDirectory) {
119-
let content = try self.getDirectoryContents(oldConfigDirectory).filter{ !$0.hasSuffix(".lock") }
120-
for item in content {
121-
if self.isFile(oldConfigDirectory.appending(component: item)) &&
122-
!self.isSymlink(oldConfigDirectory.appending(component: item)) &&
123-
!self.exists(idiomaticConfigurationDirectory.appending(component: item)) {
124-
observabilityScope?.emit(warning: "Usage of \(oldConfigDirectory.appending(component: item)) has been deprecated. Please delete it and use the new \(idiomaticConfigurationDirectory.appending(component: item)) instead.")
125-
try self.copy(from: oldConfigDirectory.appending(component: item), to: idiomaticConfigurationDirectory.appending(component: item))
120+
let configurationFiles = try self.getDirectoryContents(oldConfigDirectory)
121+
.map{ oldConfigDirectory.appending(component: $0) }
122+
.filter{ self.isFile($0) && !self.isSymlink($0) && $0.extension != "lock"}
123+
for file in configurationFiles {
124+
let destination = idiomaticConfigurationDirectory.appending(component: file.basename)
125+
observabilityScope?.emit(warning: "Usage of \(file) has been deprecated. Please delete it and use the new \(destination) instead.")
126+
if !self.exists(destination) {
127+
try self.copy(from: file, to: destination)
126128
}
127129
}
128130
}

0 commit comments

Comments
 (0)