Fix running command from Terminal

Running from the terminal would fail with a
`missingValue(argument: Optional("BUILD_ROOT"))` error. Even when
the `-i` CLI parameter was provided. This moves the fallback logic
to only run when a fallback needs to be found.
This commit is contained in:
Aron Cedercrantz 2019-12-20 16:10:43 -05:00 committed by GitHub
parent cf7f944af4
commit 2a97232cb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions

View File

@ -26,14 +26,13 @@ fileprivate func main(_ arguments: [String]) -> Int32 {
}
private func createConfiguration(options: CommandLineOptions) throws -> Configuration {
let processInfo = ProcessInfo()
/// Find the index path, default is ~Library/Developer/Xcode/DerivedData/<target>/Index/DataStore
let buildRoot = try processInfo.environmentVariable(name: EnvironmentKeys.buildRoot)
let indexStorePath: AbsolutePath
if let indexStorePathString = options.indexStorePath {
indexStorePath = AbsolutePath(indexStorePathString)
} else {
let processInfo = ProcessInfo()
// Find the index path, default is ~Library/Developer/Xcode/DerivedData/<target>/Index/DataStore
let buildRoot = try processInfo.environmentVariable(name: EnvironmentKeys.buildRoot)
let buildRootPath = AbsolutePath(buildRoot)
indexStorePath = buildRootPath.parentDirectory.parentDirectory.appending(component: "Index/DataStore")
}