Skip to content

Commit

Permalink
Merge pull request #156 from unoplatform/gh154
Browse files Browse the repository at this point in the history
fix: change suggestion if xcode-select --install fails
  • Loading branch information
jeromelaban authored Jul 13, 2023
2 parents 27d3c62 + 8787d0c commit 1455077
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions UnoCheck/Checkups/XCodeCheckup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ public string VersionName
public override bool ShouldExamine(SharedState history)
=> Manifest?.Check?.XCode != null;

private int install_tries;

public override Task<DiagnosticResult> Examine(SharedState history)
{
try
{
var selected = GetSelectedXCode();

if (selected.Version.IsCompatible(MinimumVersion, ExactVersion))
if (selected is not null && selected.Version.IsCompatible(MinimumVersion, ExactVersion))
{
// Selected version is good
ReportStatus($"Xcode.app ({VersionName})", Status.Ok);
Expand Down Expand Up @@ -90,21 +92,24 @@ public override Task<DiagnosticResult> Examine(SharedState history)
}
catch(InvalidDataException)
{
install_tries++;
return Task.FromResult(new DiagnosticResult(
Status.Error,
this,
new Suggestion("Run xcode-select --install",
new Solutions.ActionSolution((sln, cancelToken) =>
{
var result = ShellProcessRunner.Run("xcode-select", "--install");

if(result.ExitCode == 0)
install_tries > 1 ?
new Suggestion($"Download XCode {VersionName}") :
new Suggestion("Run xcode-select --install",
new Solutions.ActionSolution((sln, cancelToken) =>
{
this.Examine(history);
}
var result = ShellProcessRunner.Run("xcode-select", "--install");

return Task.CompletedTask;
}))));
if(result.ExitCode == 0)
{
this.Examine(history);
}

return Task.CompletedTask;
}))));
}
}

Expand Down

0 comments on commit 1455077

Please sign in to comment.