• R/O
  • HTTP
  • SSH
  • HTTPS

提交

Frequently used words (click to add to your profile)

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

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


Commit MetaInfo

修訂c18bdde6c419289c79816f3c5287eeefbb39e931 (tree)
時間2018-05-25 22:36:36
作者masakih <masakih@user...>
Commitermasakih

Log Message

<<< でカレントディレクトリを設定できるようにした

Change Summary

差異

--- a/AppBuilderWithGit/Carthage.swift
+++ b/AppBuilderWithGit/Carthage.swift
@@ -61,8 +61,9 @@ final class Carthage {
6161 throw CarthageError.commandNotFound
6262 }
6363
64- let carthage = Process() <<< carthageURL.path <<< ["bootstrap"]
65- carthage.currentDirectoryPath = cartfile.deletingLastPathComponent().path
64+ let carthage = Process() <<< ExcutableURL(url: carthageURL)
65+ <<< ["bootstrap"]
66+ <<< cartfile.deletingLastPathComponent()
6667
6768 carthage >>> { output, error in
6869
--- a/AppBuilderWithGit/CocoaPods.swift
+++ b/AppBuilderWithGit/CocoaPods.swift
@@ -61,8 +61,9 @@ final class CocoaPods {
6161 throw CarthageError.commandNotFound
6262 }
6363
64- let pod = Process() <<< podURL.path <<< ["install"]
65- pod.currentDirectoryPath = podfile.deletingLastPathComponent().path
64+ let pod = Process() <<< ExcutableURL(url: podURL)
65+ <<< ["install"]
66+ <<< podfile.deletingLastPathComponent()
6667
6768 pod >>> { output, error in
6869
--- a/AppBuilderWithGit/CommandFinder.swift
+++ b/AppBuilderWithGit/CommandFinder.swift
@@ -10,7 +10,7 @@ import Foundation
1010
1111 func existCommand(_ commandName: String) -> Bool {
1212
13- let which = Process() <<< "/usr/bin/which" <<< [commandName]
13+ let which = Process() <<< ExcutableURL(fileURLWithPath: "/usr/bin/which") <<< [commandName]
1414
1515 if let currentPath = which.environment?["PATH"] {
1616
@@ -26,7 +26,7 @@ func existCommand(_ commandName: String) -> Bool {
2626
2727 func commandPath(_ commandName: String) -> URL? {
2828
29- let which = Process() <<< "/usr/bin/which" <<< [commandName]
29+ let which = Process() <<< ExcutableURL(fileURLWithPath: "/usr/bin/which") <<< [commandName]
3030
3131 if let currentPath = which.environment?["PATH"] {
3232
@@ -42,6 +42,7 @@ func commandPath(_ commandName: String) -> URL? {
4242 let lines = output.lines
4343
4444 guard let path = lines.first else {
45+
4546 return nil
4647 }
4748
--- a/AppBuilderWithGit/Git.swift
+++ b/AppBuilderWithGit/Git.swift
@@ -87,9 +87,9 @@ final class Git {
8787 throw GitError.other("URL is invalid")
8888 }
8989
90- let git = Process() <<< gitURL.path <<< args
91-
92- git.currentDirectoryPath = workingURL.path
90+ let git = Process() <<< ExcutableURL(url: gitURL)
91+ <<< args
92+ <<< workingURL
9393
9494 let errorString = git >>> { (stdout, stderr) -> String in
9595
@@ -108,7 +108,6 @@ final class Git {
108108
109109 throw GitError.gitError(git.terminationStatus, errorString)
110110 }
111-
112111 }
113112
114113 private func clone() throws {
@@ -177,6 +176,5 @@ final class Git {
177176 }
178177
179178 return url.lastPathComponent
180-
181179 }
182180 }
--- a/AppBuilderWithGit/Process-extensions.swift
+++ b/AppBuilderWithGit/Process-extensions.swift
@@ -14,22 +14,41 @@ struct Output {
1414 private let fileHandle: FileHandle
1515
1616 init(fileHandle: FileHandle) {
17+
1718 self.fileHandle = fileHandle
1819 }
1920
2021 var data: Data {
22+
2123 return fileHandle.readDataToEndOfFile()
2224 }
2325
2426 var string: String? {
27+
2528 return String(data: data, encoding: .utf8)
2629 }
2730
2831 var lines: [String] {
32+
2933 return string?.components(separatedBy: "\n") ?? []
3034 }
3135 }
3236
37+struct ExcutableURL {
38+
39+ let url: URL
40+
41+ init(fileURLWithPath path: String) {
42+
43+ url = URL(fileURLWithPath: path)
44+ }
45+
46+ init(url: URL) {
47+
48+ self.url = url
49+ }
50+}
51+
3352 precedencegroup ArgumentPrecedence {
3453
3554 associativity: left
@@ -38,9 +57,17 @@ precedencegroup ArgumentPrecedence {
3857 infix operator <<< : ArgumentPrecedence
3958
4059 /// Processにexecutable pathを設定する。
41-func <<< (lhs: Process, rhs: String) -> Process {
60+func <<< (lhs: Process, rhs: ExcutableURL) -> Process {
61+
62+ if #available(macOS 10.13, *) {
63+
64+ lhs.executableURL = rhs.url
65+
66+ } else {
67+
68+ lhs.launchPath = rhs.url.path
69+ }
4270
43- lhs.launchPath = rhs
4471 return lhs
4572 }
4673
@@ -48,6 +75,22 @@ func <<< (lhs: Process, rhs: String) -> Process {
4875 func <<< (lhs: Process, rhs: [String]) -> Process {
4976
5077 lhs.arguments = rhs
78+
79+ return lhs
80+}
81+
82+/// Current directoryを設定する。
83+func <<< (lhs: Process, rhs: URL) -> Process {
84+
85+ if #available(macOS 10.13, *) {
86+
87+ lhs.currentDirectoryURL = rhs
88+
89+ } else {
90+
91+ lhs.currentDirectoryPath = rhs.path
92+ }
93+
5194 return lhs
5295 }
5396
--- a/AppBuilderWithGit/ProjectBuilder.swift
+++ b/AppBuilderWithGit/ProjectBuilder.swift
@@ -33,7 +33,6 @@ final class ProjectBuilder {
3333 }
3434
3535 self.info = info
36-
3736 }
3837
3938 var productURL: URL { return info.productURL }
@@ -52,8 +51,10 @@ final class ProjectBuilder {
5251 throw ProjectBuilderError.other("URL is Invalid.")
5352 }
5453
55- let xcodebuild = Process() <<< builderURL.path <<< info.arguments
56- xcodebuild.currentDirectoryPath = info.projectURL.path
54+ let xcodebuild = Process() <<< ExcutableURL(url: builderURL)
55+ <<< info.arguments
56+ <<< info.projectURL
57+
5758 xcodebuild >>> { stdout, stderr in
5859
5960 let log = LogStocker("xcodebuild.log")
@@ -68,6 +69,4 @@ final class ProjectBuilder {
6869 throw ProjectBuilderError.commandFail
6970 }
7071 }
71-
72-
7372 }