Skip to content

Commit 6aea3c9

Browse files
committed
Change a force unwrap to an internal error, and remove some unnecessary formatting of the JSON encoding.
1 parent ab655b1 commit 6aea3c9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sources/SPMBuildCore/ExtensionEvaluator.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
import Foundation
12+
import Basics
1213
import PackageModel
1314
import PackageGraph
1415
import TSCBasic
@@ -55,7 +56,9 @@ extension PackageGraph {
5556

5657
// If this target does use any extensions, create the input context to pass to them.
5758
// FIXME: We'll want to decide on what directories to provide to the extenion
58-
let package = self.packages.first{ $0.targets.contains(target) }!
59+
guard let package = self.packages.first(where: { $0.targets.contains(target) }) else {
60+
throw InternalError("could not find package for target \(target)")
61+
}
5962
let extOutputsDir = outputDir.appending(components: "extensions", package.name, target.c99name, "outputs")
6063
let extCachesDir = outputDir.appending(components: "extensions", package.name, target.c99name, "caches")
6164
let extensionInput = ExtensionEvaluationInput(
@@ -159,7 +162,6 @@ extension PackageGraph {
159162
fileprivate func runExtension(sources: Sources, input: ExtensionEvaluationInput, extensionRunner: ExtensionRunner, diagnostics: DiagnosticsEngine, fileSystem: FileSystem) throws -> (output: ExtensionEvaluationOutput, stdoutText: Data) {
160163
// Serialize the ExtensionEvaluationInput to JSON.
161164
let encoder = JSONEncoder()
162-
encoder.outputFormatting = [.prettyPrinted, .withoutEscapingSlashes]
163165
let inputJSON = try encoder.encode(input)
164166

165167
// Call the extension runner.

0 commit comments

Comments
 (0)