• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

gitリポジトリのurlを貼り付けるだけでアプリケーションのビルドを実行するアプリ。 macOS用


Commit MetaInfo

Revisiónb2f398418e58f76b7354bac497d2fd8592dddf85 (tree)
Tiempo2018-04-08 14:17:21
Autormasakih <masakih@user...>
Commitermasakih

Log Message

例外を投げるようにした

Cambiar Resumen

Diferencia incremental

--- a/AppBuilderWithGit/Carthage.swift
+++ b/AppBuilderWithGit/Carthage.swift
@@ -8,6 +8,13 @@
88
99 import Foundation
1010
11+enum CarthageError: Error {
12+
13+ case commandNotFound
14+
15+ case commandFail
16+}
17+
1118 final class Carthage {
1219
1320 let baseURL: URL
@@ -42,7 +49,7 @@ final class Carthage {
4249 return true
4350 }
4451
45- func execute() {
52+ func execute() throws {
4653
4754 guard let cartfile = cartfileURL else {
4855
@@ -51,15 +58,15 @@ final class Carthage {
5158
5259 guard let carthageURL = carthageURL else {
5360
54- return
61+ throw CarthageError.commandNotFound
5562 }
5663
57- let log = LogStocker("carthage.log")
58-
5964 let carthage = Process() <<< carthageURL.path <<< ["update"]
6065 carthage.currentDirectoryPath = cartfile.deletingLastPathComponent().path
6166
6267 carthage >>> { output, error in
68+
69+ let log = LogStocker("carthage.log")
6370 log?.write(output.data)
6471 log?.write(error.data)
6572 }
@@ -67,7 +74,7 @@ final class Carthage {
6774
6875 if carthage.terminationStatus != 0 {
6976
70- log?.write("Carthage error exit with status \(carthage.terminationStatus)")
77+ throw CarthageError.commandFail
7178 }
7279 }
7380 }
--- a/AppBuilderWithGit/ViewController.swift
+++ b/AppBuilderWithGit/ViewController.swift
@@ -112,7 +112,10 @@ extension ViewController {
112112 case .none:
113113 self.message = "Finish cloning"
114114
115- self.carthage(gitCloner.repository)
115+ guard self.carthage(gitCloner.repository) else {
116+
117+ return
118+ }
116119
117120 self.build(gitCloner.repository)
118121
@@ -127,20 +130,31 @@ extension ViewController {
127130 }
128131 }
129132
130- private func carthage(_ url: URL) {
133+ private func carthage(_ url: URL) -> Bool {
131134
132135 message = "Checking Carthage."
133136
134- let carthage = Carthage(url)
135-
136- guard carthage.checkCarthage() else {
137+ do {
138+
139+ let carthage = Carthage(url)
140+
141+ guard carthage.checkCarthage() else {
142+
143+ return true
144+ }
145+
146+ message = "Building frameworks with Carthage."
137147
138- return
148+ try carthage.execute()
149+
150+ return true
151+
152+ } catch {
153+
154+ message = "Fail to carthage."
155+
156+ return false
139157 }
140-
141- message = "Building frameworks with Carthage."
142-
143- carthage.execute()
144158 }
145159
146160 private func build(_ url: URL) {