Add --project-root option to generate command. (#828)

This commit is contained in:
Ian Leitch 2020-04-08 21:20:54 +02:00 committed by GitHub
parent 7afcf1f5f7
commit b1edbda583
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -4,6 +4,7 @@
#### Added
- Improve speed of metadata parsing and dependency resolution. [#803](https://github.com/yonaskolb/XcodeGen/pull/803) @michaeleisel
- Improve support for iOS sticker packs and add support for `launchAutomaticallySubstyle` to run schemes. [#824](https://github.com/yonaskolb/XcodeGen/pull/824) @scelis
- Add --project-root option to generate command. [#828](https://github.com/yonaskolb/XcodeGen/pull/828) @ileitch
#### Fixed
- Fixed issue when linking and embeding static frameworks: they should be linked and NOT embed. [#820](https://github.com/yonaskolb/XcodeGen/pull/820) @acecilia

View File

@ -15,10 +15,10 @@ public class SpecLoader {
self.version = version
}
public func loadProject(path: Path, variables: [String: String] = [:]) throws -> Project {
public func loadProject(path: Path, projectRoot: Path? = nil, variables: [String: String] = [:]) throws -> Project {
let spec = try SpecFile(path: path)
let resolvedDictionary = spec.resolvedDictionary(variables: variables)
let project = try Project(basePath: spec.basePath, jsonDictionary: resolvedDictionary)
let project = try Project(basePath: projectRoot ?? spec.basePath, jsonDictionary: resolvedDictionary)
self.project = project
projectDictionary = resolvedDictionary

View File

@ -15,6 +15,9 @@ class ProjectCommand: Command {
@Key("-s", "--spec", description: "The path to the project spec file. Defaults to project.yml")
var spec: Path?
@Key("-r", "--project-root", description: "The path to the project root directory. Defaults to the directory containing the project spec.")
var projectRoot: Path?
@Flag("-n", "--no-env", description: "Disable environment variable expansions")
var disableEnvExpansion: Bool
@ -38,7 +41,7 @@ class ProjectCommand: Command {
let variables: [String: String] = disableEnvExpansion ? [:] : ProcessInfo.processInfo.environment
do {
project = try specLoader.loadProject(path: projectSpecPath, variables: variables)
project = try specLoader.loadProject(path: projectSpecPath, projectRoot: projectRoot, variables: variables)
} catch {
throw GenerationError.projectSpecParsingError(error)
}