mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2026-03-18 20:02:25 +00:00
Fix review suggestions
This commit is contained in:
@@ -82,9 +82,9 @@ public struct SpecFile {
|
||||
}
|
||||
}
|
||||
|
||||
public func resolvedDictionary(environmentVariables: [String: String] = ProcessInfo.processInfo.environment) -> JSONDictionary {
|
||||
public func resolvedDictionary(variables: [String: String] = [:]) -> JSONDictionary {
|
||||
var resolvedSpec = resolvingPaths().mergedDictionary()
|
||||
for (key, value) in environmentVariables {
|
||||
for (key, value) in variables {
|
||||
resolvedSpec = resolvedSpec.replaceString("${\(key)}", with: value)
|
||||
}
|
||||
return resolvedSpec
|
||||
|
||||
@@ -58,7 +58,7 @@ class GenerateCommand: Command {
|
||||
|
||||
// load project spec
|
||||
do {
|
||||
project = try specLoader.loadProject(path: projectSpecPath)
|
||||
project = try specLoader.loadProject(path: projectSpecPath, variables: ProcessInfo.processInfo.environment)
|
||||
info("Loaded project:\n \(project.debugDescription.replacingOccurrences(of: "\n", with: "\n "))")
|
||||
} catch {
|
||||
throw GenerationError.projectSpecParsingError(error)
|
||||
|
||||
@@ -15,9 +15,9 @@ public class SpecLoader {
|
||||
self.version = version
|
||||
}
|
||||
|
||||
public func loadProject(path: Path, environmentVariables: [String: String] = ProcessInfo.processInfo.environment) throws -> Project {
|
||||
public func loadProject(path: Path, variables: [String: String] = [:]) throws -> Project {
|
||||
let spec = try SpecFile(path: path)
|
||||
let resolvedDictionary = spec.resolvedDictionary(environmentVariables: environmentVariables)
|
||||
let resolvedDictionary = spec.resolvedDictionary(variables: variables)
|
||||
let project = try Project(basePath: spec.basePath, jsonDictionary: resolvedDictionary)
|
||||
|
||||
self.project = project
|
||||
|
||||
@@ -42,7 +42,7 @@ class FixturePerformanceTests: XCTestCase {
|
||||
|
||||
func testCacheFileGeneration() throws {
|
||||
let specLoader = SpecLoader(version: "1.2")
|
||||
_ = try specLoader.loadProject(path: specPath, environmentVariables: [:])
|
||||
_ = try specLoader.loadProject(path: specPath)
|
||||
|
||||
measure {
|
||||
_ = try! specLoader.generateCacheFile()
|
||||
|
||||
@@ -189,7 +189,7 @@ class SpecLoadingTests: XCTestCase {
|
||||
|
||||
$0.it("expands environment variables") {
|
||||
let path = fixturePath + "env_test.yml"
|
||||
let project = try loadSpec(path: path, environmentVariables: ["SETTING1": "ENV VALUE1", "SETTING4": "ENV VALUE4"])
|
||||
let project = try loadSpec(path: path, variables: ["SETTING1": "ENV VALUE1", "SETTING4": "ENV VALUE4"])
|
||||
|
||||
try expect(project.name) == "NewName"
|
||||
try expect(project.settingGroups) == [
|
||||
@@ -250,7 +250,7 @@ class SpecLoadingTests: XCTestCase {
|
||||
try? Yams.dump(object: dictionary).write(toFile: path.string, atomically: true, encoding: .utf8)
|
||||
let specLoader = SpecLoader(version: "1.1.0")
|
||||
do {
|
||||
_ = try specLoader.loadProject(path: path, environmentVariables: [:])
|
||||
_ = try specLoader.loadProject(path: path)
|
||||
} catch {
|
||||
throw failure("\(error)")
|
||||
}
|
||||
@@ -280,7 +280,7 @@ class SpecLoadingTests: XCTestCase {
|
||||
try? Yams.dump(object: dictionary).write(toFile: path.string, atomically: true, encoding: .utf8)
|
||||
let specLoader = SpecLoader(version: "1.1.0")
|
||||
do {
|
||||
_ = try specLoader.loadProject(path: path, environmentVariables: [:])
|
||||
_ = try specLoader.loadProject(path: path)
|
||||
} catch {
|
||||
throw failure("\(error)")
|
||||
}
|
||||
@@ -965,10 +965,10 @@ fileprivate func getProjectSpec(_ project: [String: Any], file: String = #file,
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate func loadSpec(path: Path, environmentVariables: [String: String] = [:], file: String = #file, line: Int = #line) throws -> Project {
|
||||
fileprivate func loadSpec(path: Path, variables: [String: String] = [:], file: String = #file, line: Int = #line) throws -> Project {
|
||||
do {
|
||||
let specLoader = SpecLoader(version: "1.1.0")
|
||||
return try specLoader.loadProject(path: path, environmentVariables: environmentVariables)
|
||||
return try specLoader.loadProject(path: path, variables: variables)
|
||||
} catch {
|
||||
throw failure("\(error)", file: file, line: line)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user