Skip to content

Commit

Permalink
Give better error message if GitHub CLI or GIT isn't installed (#898)
Browse files Browse the repository at this point in the history
Fixes #870

---------

Co-authored-by: freddydk <freddydk@users.noreply.github.com>
  • Loading branch information
freddydk and freddydk authored Jan 26, 2024
1 parent 2fe598c commit 5000d6c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Actions/AL-Go-Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ function RetryCommand {
catch {
$retryCount++
if ($retryCount -eq $MaxRetries) {
throw $_
throw
}
else {
Write-Host "Retrying after $RetryDelaySeconds seconds..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
& /usr/bin/env sudo pwsh -command "& chmod +x $ENV:aldocPath"
}
Write-Host "Installing/Updating docfx"
CmdDo -command dotnet -arguments @("tool","update","-g docfx")
CmdDo -command dotnet -arguments @("tool","update","-g docfx") -messageIfCmdNotFound "dotnet not found. Please install it from https://dotnet.microsoft.com/download"
}
return $ENV:aldocPath
}
Expand Down
24 changes: 19 additions & 5 deletions Actions/Github-Helper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ function CmdDo {
[string] $arguments = "",
[switch] $silent,
[switch] $returnValue,
[string] $inputStr = ""
[string] $inputStr = "",
[string] $messageIfCmdNotFound = ""
)

$oldNoColor = "$env:NO_COLOR"
Expand Down Expand Up @@ -282,14 +283,27 @@ function CmdDo {
Write-Host $message
}
if ($returnValue) {
$message.Replace("`r","").Split("`n")
$message.Replace("`r", "").Split("`n")
}
}
else {
$message += "`n`nExitCode: "+$p.ExitCode + "`nCommandline: $command $arguments"
$message += "`n`nExitCode: " + $p.ExitCode + "`nCommandline: $command $arguments"
throw $message
}
}
catch [System.ComponentModel.Win32Exception] {
if ($_.Exception.NativeErrorCode -eq 2) {
if ($messageIfCmdNotFound) {
throw $messageIfCmdNotFound
}
else {
throw "Command $command not found, you might need to install that command."
}
}
else {
throw
}
}
finally {
try { [Console]::OutputEncoding = $oldEncoding } catch {}
$env:NO_COLOR = $oldNoColor
Expand Down Expand Up @@ -319,7 +333,7 @@ function invoke-gh {
$arguments += "$parameter "
}
}
cmdDo -command gh -arguments $arguments -silent:$silent -returnValue:$returnValue -inputStr $inputStr
cmdDo -command gh -arguments $arguments -silent:$silent -returnValue:$returnValue -inputStr $inputStr -messageIfCmdNotFound "Github CLI not found. Please install it from https://cli.github.com/"
}
}

Expand All @@ -343,7 +357,7 @@ function invoke-git {
$arguments += "$parameter "
}
}
cmdDo -command git -arguments $arguments -silent:$silent -returnValue:$returnValue -inputStr $inputStr
cmdDo -command git -arguments $arguments -silent:$silent -returnValue:$returnValue -inputStr $inputStr -messageIfCmdNotFound "Git not found. Please install it from https://git-scm.com/downloads"
}
}

Expand Down
1 change: 1 addition & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Note that when using the preview version of AL-Go for GitHub, we recommend you U

### Issues
- Support release branches that start with releases/
- Issue 870 Improve Error Handling when CLI is missing

### Build modes
AL-Go ships with Default, Translated and Clean mode out of the box. Now you can also define custom build modes in addition to the ones shipped with AL-Go. This allows you to define your own build modes, which can be used to build your apps in different ways. By default, a custom build mode will build the apps similarly to the Default mode but this behavior can be overridden in e.g. script overrides in your repository.
Expand Down

0 comments on commit 5000d6c

Please sign in to comment.