mirror of
https://github.com/nicklockwood/SwiftFormat.git
synced 2026-06-16 10:34:34 +00:00
Fixed error when --exclude matched no files
This commit is contained in:
@@ -257,8 +257,14 @@ func processArguments(_ args: [String], in directory: String) -> ExitCode {
|
||||
// Ensure exclude paths in config file are treated as relative to the file itself
|
||||
// TODO: find a better way/place to do this
|
||||
let directory = configURL.deletingLastPathComponent().path
|
||||
if let excluded = config["exclude"].map({ expandGlobs($0, in: directory) }) {
|
||||
config["exclude"] = excluded.map { $0.path }.sorted().joined(separator: ",")
|
||||
if let exclude = config["exclude"] {
|
||||
let excluded = expandGlobs(exclude, in: directory)
|
||||
if excluded.isEmpty {
|
||||
print("warning: --exclude value '\(exclude)' did not match any files in \(directory)", as: .warning)
|
||||
config["exclude"] = nil
|
||||
} else {
|
||||
config["exclude"] = excluded.map { $0.path }.sorted().joined(separator: ",")
|
||||
}
|
||||
}
|
||||
args = try mergeArguments(args, into: config)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user