Skip to content

Commit e73d50b

Browse files
committed
Check for error reason and expected type
1 parent 3d76d22 commit e73d50b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Sources/ProjectSpec/Project.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,14 @@ extension Project {
194194
include = jsonDictionary.json(atKeyPath: "include") ?? []
195195
if jsonDictionary["packages"] != nil {
196196
packages = try jsonDictionary.json(atKeyPath: "packages", invalidItemBehaviour: .custom({ error in
197+
guard error.reason == .incorrectType && type(of: error.expectedType.self) == String.Type.self else {
198+
return .fail
199+
}
197200
var pairs = [(String, Any)]()
198201
for item in error.dictionary {
199202
pairs.append((
200203
item.key as? String ?? "",
201-
(item.value as? Double).map { String($0) + ".0" } ?? item.value
204+
(item.value as? Double).map { String($0) } ?? item.value
202205
))
203206
}
204207
return (try? .value(.init(jsonDictionary: .init(uniqueKeysWithValues: pairs)))) ?? .fail

0 commit comments

Comments
 (0)