fix indexStorePath

This commit is contained in:
Roy Cao 2019-12-04 00:37:23 +08:00
parent 6253af5fba
commit 5c052f5493
1 changed files with 20 additions and 10 deletions

View File

@ -21,7 +21,7 @@ fileprivate func main(_ arguments: [String]) -> Int32 {
return 1
}
case .version:
print("0.0.2")
print("0.0.3")
return 0
}
}
@ -29,7 +29,14 @@ fileprivate func main(_ arguments: [String]) -> Int32 {
private func createConfiguration(options: CommandLineOptions) throws -> Configuration {
let processInfo = ProcessInfo()
let targetName = try processInfo.environmentVariable(name: EnvironmentKeys.target)
let indexStorePath = try findIndexFile(targetName: targetName)
/// Find the index path, default is ~Library/Developer/Xcode/DerivedData/<target>/Index/DataStore
let buildRoot = try processInfo.environmentVariable(name: EnvironmentKeys.buildRoot)
guard let buildRootPath = Path(buildRoot),
let indexStorePath = Path(buildRootPath.parent.parent.url.path+"/Index/DataStore") else {
throw PEError.findIndexFailed(message: "find project: \(targetName) index under DerivedData failed")
}
guard let cwd = localFileSystem.currentWorkingDirectory else {
throw PEError.fiendCurrentWorkingDirectoryFailed
}
@ -39,11 +46,12 @@ private func createConfiguration(options: CommandLineOptions) throws -> Configur
throw PEError.findProjectFileFailed(message: "find project: \(targetName) Path failed")
}
let configuration = Configuration(projectPath: projectPath, indexStorePath: indexStorePath)
let configuration = Configuration(projectPath: projectPath, indexStorePath: indexStorePath.url.path)
return configuration
}
/*
/// Find the index path, default is ~Library/Developer/Xcode/DerivedData/<target>/Index/DataStore
private func findIndexFile(targetName: String) throws -> String {
let url = URL(fileURLWithPath: NSHomeDirectory()).appendingPathComponent("Library/Developer/Xcode/DerivedData")
@ -61,6 +69,7 @@ private func findIndexFile(targetName: String) throws -> String {
}
throw PEError.findIndexFailed(message: "find project: \(targetName) index under DerivedData failed")
}
*/
private extension ProcessInfo {
func environmentVariable(name: String) throws -> String {
@ -80,6 +89,7 @@ struct EnvironmentKeys {
static let target = "TARGET_NAME"
static let tempDir = "TEMP_DIR"
static let xcodeproj = "PROJECT_FILE_PATH"
static let buildRoot = "BUILD_ROOT"
}
enum ProcessError: Error {