diff --git a/SourceTree.alfredworkflow b/SourceTree.alfredworkflow index 4eef8ce..b5043ac 100644 Binary files a/SourceTree.alfredworkflow and b/SourceTree.alfredworkflow differ diff --git a/workflow.swift b/workflow.swift index 5484101..06466af 100755 --- a/workflow.swift +++ b/workflow.swift @@ -163,10 +163,14 @@ class SourceTree: Workflow { emptyMessage = AlfredItem(title: "Your SourceTree Bookmark Is Empty ", subtitle: "Please add repos to SourceTree first") - guard let data = try? Data(contentsOf: Self.plistPath) else { + guard Self.isSourceTreeInstalled() else { errorMessage = AlfredItem(title: "SourceTree not installed", subtitle: "Press enter to open SourceTree homepage and download it", arg: "open \"https://sourcetreeapp.com/\"") return } + guard let data = try? Data(contentsOf: Self.plistPath) else { + errorMessage = emptyMessage + return + } do { let parsed = try PropertyListDecoder().decode(SourceTreePlist.self, from: data) @@ -237,6 +241,10 @@ class SourceTree: Workflow { let url = FileManager.default.homeDirectoryForCurrentUser return url.appendingPathComponent("Library/Application Support/SourceTree/browser.plist") } + + static func isSourceTreeInstalled() -> Bool { + return FileManager.default.fileExists(atPath: "/Applications/SourceTree.app") + } } // MARK: SourceTree Plist