mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2024-09-21 01:28:24 +03:00
add optional replace syntax when merging includes
This commit is contained in:
parent
957493855c
commit
c9c589c5ee
@ -6,6 +6,8 @@ settingGroups:
|
||||
MY_SETTING3: VALUE3
|
||||
new:
|
||||
MY_SETTING: VALUE
|
||||
toReplace:REPLACE:
|
||||
MY_SETTING2: VALUE2
|
||||
targets:
|
||||
NewTarget:
|
||||
type: application
|
||||
@ -13,4 +15,4 @@ targets:
|
||||
IncludedTarget:
|
||||
name: IncludedTargetNew
|
||||
platform: tvOS
|
||||
sources: Target
|
||||
sources:REPLACE: NewSource
|
||||
|
@ -3,7 +3,11 @@ settingGroups:
|
||||
test:
|
||||
MY_SETTING1: VALUE1
|
||||
MY_SETTING2: VALUE2
|
||||
toReplace:
|
||||
MY_SETTING1: VALUE1
|
||||
targets:
|
||||
IncludedTarget:
|
||||
type: application
|
||||
platform: iOS
|
||||
sources:
|
||||
- Target
|
||||
|
@ -52,7 +52,10 @@ public struct SpecLoader {
|
||||
var merged = base
|
||||
|
||||
for (key, value) in dictionary {
|
||||
if let dictionary = value as? JSONDictionary, let base = merged[key] as? JSONDictionary {
|
||||
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
|
||||
|
@ -39,9 +39,10 @@ func specLoadingTests() {
|
||||
try expect(spec.settingGroups) == [
|
||||
"test": Settings(dictionary: ["MY_SETTING1": "NEW VALUE", "MY_SETTING2": "VALUE2", "MY_SETTING3": "VALUE3"]),
|
||||
"new": Settings(dictionary: ["MY_SETTING": "VALUE"]),
|
||||
"toReplace": Settings(dictionary: ["MY_SETTING2": "VALUE2"]),
|
||||
]
|
||||
try expect(spec.targets) == [
|
||||
Target(name: "IncludedTargetNew", type: .application, platform: .tvOS, sources: ["Target"]),
|
||||
Target(name: "IncludedTargetNew", type: .application, platform: .tvOS, sources: ["NewSource"]),
|
||||
Target(name: "NewTarget", type: .application, platform: .iOS),
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user