mirror of
https://github.com/github/semantic.git
synced 2024-12-26 00:12:29 +03:00
Try to make a temporary file. What could go wrong?
This commit is contained in:
parent
11eece38aa
commit
d38c8b0ff0
@ -85,7 +85,8 @@ func termWithInput(language: TSLanguage)(_ string: String) throws -> Term {
|
|||||||
let arguments = BoundsCheckedArray(array: Process.arguments)
|
let arguments = BoundsCheckedArray(array: Process.arguments)
|
||||||
guard let aSource = try arguments[1].map(Source.init) else { throw "need source A" }
|
guard let aSource = try arguments[1].map(Source.init) else { throw "need source A" }
|
||||||
guard let bSource = try arguments[2].map(Source.init) else { throw "need source B" }
|
guard let bSource = try arguments[2].map(Source.init) else { throw "need source B" }
|
||||||
guard let jsonPath = arguments[3] else { throw "need json path" }
|
let temporary = try NSFileManager.defaultManager().URLForDirectory(.ItemReplacementDirectory, inDomain: .UserDomainMask, appropriateForURL: NSURL(fileURLWithPath: Process.arguments[0]).URLByDeletingLastPathComponent!, create: true)
|
||||||
|
let jsonURL = temporary.URLByAppendingPathComponent("diff.json")
|
||||||
guard let uiPath = arguments[4] else { throw "need ui path" }
|
guard let uiPath = arguments[4] else { throw "need ui path" }
|
||||||
guard aSource.type == bSource.type else { throw "can’t compare files of different types" }
|
guard aSource.type == bSource.type else { throw "can’t compare files of different types" }
|
||||||
guard let parser = Source.languagesByType[aSource.type].map(termWithInput) else { throw "don’t know how to parse files of type \(aSource.type)" }
|
guard let parser = Source.languagesByType[aSource.type].map(termWithInput) else { throw "don’t know how to parse files of type \(aSource.type)" }
|
||||||
@ -104,12 +105,12 @@ let JSON: Doubt.JSON = [
|
|||||||
}),
|
}),
|
||||||
]
|
]
|
||||||
let data = JSON.serialize()
|
let data = JSON.serialize()
|
||||||
try data.writeToFile(jsonPath, options: .DataWritingAtomic)
|
try data.writeToURL(jsonURL, options: .DataWritingAtomic)
|
||||||
|
|
||||||
let components = NSURLComponents()
|
let components = NSURLComponents()
|
||||||
components.scheme = "file"
|
components.scheme = "file"
|
||||||
components.path = uiPath
|
components.path = uiPath
|
||||||
components.query = jsonPath
|
components.query = jsonURL.absoluteString
|
||||||
if let URL = components.URL {
|
if let URL = components.URL {
|
||||||
NSWorkspace.sharedWorkspace().openURL(URL)
|
NSWorkspace.sharedWorkspace().openURL(URL)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user