diff --git a/Sources/ApolloCodegenLib/Glob.swift b/Sources/ApolloCodegenLib/Glob.swift index 3d90c60468..0f6dcfdc64 100644 --- a/Sources/ApolloCodegenLib/Glob.swift +++ b/Sources/ApolloCodegenLib/Glob.swift @@ -125,8 +125,10 @@ public struct Glob { let isExclude = pattern.isExclude var parts = pattern.components(separatedBy: String.Globstar) var firstPart = parts.removeFirst() - let lastPart = parts.joined(separator: String.Globstar) - let lastDirComponent = lastPart.components(separatedBy: "*").first ?? "" + let last = parts.joined(separator: String.Globstar) + parts = last.components(separatedBy: "*") + let lastDirComponent = parts.removeFirst() + let lastPart = "*\(parts.joined(separator: "*"))" if isExclude { // Remove ! here otherwise the Linux glob function would not return any results. Results for @@ -186,15 +188,9 @@ public struct Glob { } return OrderedSet(directories.compactMap({ directory in - // build directory URL up the the '*' in the pattern, and check if it is a symlink, if so skip it - let symCheckURL = directory.appendingPathComponent(lastDirComponent).standardizedFileURL - if let resourceValues = try? symCheckURL.resourceValues(forKeys: [.isSymbolicLinkKey]), - let isSymLink = resourceValues.isSymbolicLink, - isSymLink { - return nil - } - - var path = directory.resolvingSymlinksInPath().appendingPathComponent(lastPart).standardizedFileURL.path + // build directory URL up to the first '*' in the pattern, and resolve symlinks + let url = directory.appendingPathComponent(lastDirComponent).standardizedFileURL.resolvingSymlinksInPath() + var path = url.appendingPathComponent("\(lastPart)").standardizedFileURL.path if isExclude { path.insert("!", at: path.startIndex) }