mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2024-09-20 00:58:04 +03:00
Replace global merge function with extension on Dictionary
This commit is contained in:
parent
8928088dfe
commit
a2684a96a4
@ -101,24 +101,6 @@ extension Dictionary where Key == String, Value: Any {
|
||||
}
|
||||
}
|
||||
|
||||
func merge(dictionary: JSONDictionary, onto base: JSONDictionary) -> JSONDictionary {
|
||||
var merged = base
|
||||
|
||||
for (key, value) in dictionary {
|
||||
if key.hasSuffix(":REPLACE") {
|
||||
let newKey = key.replacingOccurrences(of: ":REPLACE", with: "")
|
||||
merged[newKey] = value
|
||||
} else if let dictionary = value as? JSONDictionary, let base = merged[key] as? JSONDictionary {
|
||||
merged[key] = merge(dictionary: dictionary, onto: base)
|
||||
} else if let array = value as? [Any], let base = merged[key] as? [Any] {
|
||||
merged[key] = base + array
|
||||
} else {
|
||||
merged[key] = value
|
||||
}
|
||||
}
|
||||
return merged
|
||||
}
|
||||
|
||||
public func += (lhs: inout BuildSettings, rhs: BuildSettings?) {
|
||||
guard let rhs = rhs else { return }
|
||||
lhs.merge(rhs)
|
||||
|
@ -125,10 +125,10 @@ extension Target {
|
||||
var mergedDictionary: JSONDictionary = [:]
|
||||
for template in templates {
|
||||
if let templateDictionary = targetTemplatesDictionary[template] {
|
||||
mergedDictionary = merge(dictionary: templateDictionary, onto: mergedDictionary)
|
||||
mergedDictionary = templateDictionary.merged(onto: mergedDictionary)
|
||||
}
|
||||
}
|
||||
target = merge(dictionary: target, onto: mergedDictionary)
|
||||
target = target.merged(onto: mergedDictionary)
|
||||
}
|
||||
targetsDictionary[targetName] = target
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user