-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #180 from tahirmt/do-not-hard-exit-if-xcode-alread…
…y-installed Do not exit(1) if xcode is already installed
- Loading branch information
Showing
2 changed files
with
32 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import ArgumentParser | ||
import Foundation | ||
import LegibleError | ||
import PromiseKit | ||
import XcodesKit | ||
import Rainbow | ||
|
||
extension ParsableArguments { | ||
static func processDownloadOrInstall(error: Error) -> Never { | ||
var exitCode: ExitCode = .failure | ||
switch error { | ||
case Process.PMKError.execution(let process, let standardOutput, let standardError): | ||
Current.logging.log(""" | ||
Failed executing: `\(process)` (\(process.terminationStatus)) | ||
\([standardOutput, standardError].compactMap { $0 }.joined(separator: "\n")) | ||
""".red) | ||
case let error as XcodeInstaller.Error: | ||
if case .versionAlreadyInstalled = error { | ||
Current.logging.log(error.legibleLocalizedDescription.green) | ||
exitCode = .success | ||
} else { | ||
Current.logging.log(error.legibleLocalizedDescription.red) | ||
} | ||
default: | ||
Current.logging.log(error.legibleLocalizedDescription.red) | ||
} | ||
|
||
Self.exit(withError: exitCode) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters