aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-12-24 21:55:54 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-12-24 21:55:54 +0300
commit84eaf929144e40e16784ce145e6640736215a016 (patch)
tree74df70827f52f56b90a77899698b7b94fa4c0386
parent/usr/local/bin should come first in PATH (diff)
downloadsetup-cygwin-84eaf929144e40e16784ce145e6640736215a016.tar.gz
setup-cygwin-84eaf929144e40e16784ce145e6640736215a016.zip
use well-known path to choco.exe if not in PATH
-rw-r--r--action.yml15
1 files changed, 13 insertions, 2 deletions
diff --git a/action.yml b/action.yml
index 82f1c27..9de9583 100644
--- a/action.yml
+++ b/action.yml
@@ -29,9 +29,20 @@ runs:
New-Variable install_dir -Value '${{ inputs.install-dir }}' -Option Constant
New-Variable packages -Value '${{ inputs.packages }}' -Option Constant
+ function Locate-Choco {
+ $path = Get-Command 'choco' -ErrorAction SilentlyContinue
+ if ($path) {
+ $path.Path
+ } else {
+ Join-Path ${env:ProgramData} 'chocolatey' 'bin' 'choco'
+ }
+ }
+
if ($windows_host) {
echo 'CYGWIN=${{ inputs.env }}' >> $env:GITHUB_ENV
+ $choco = Locate-Choco
+
$choco_params = @(
'install',
'-y',
@@ -44,7 +55,7 @@ runs:
$choco_params += 'cygwin'
# Assuming that Cygwin is not installed when this is run.
- choco.exe $choco_params
+ & $choco $choco_params
# /usr/bin is really just /bin on Cygwin.
echo (Join-Path $install_dir bin) >> $env:GITHUB_PATH
@@ -53,7 +64,7 @@ runs:
$pkg_list = $packages.Split(' ', [System.StringSplitOptions]::RemoveEmptyEntries)
if ($pkg_list.Count -gt 0) {
- choco.exe install -y --no-progress --source=cygwin $pkg_list
+ & $choco install -y --no-progress --source=cygwin $pkg_list
}
} else {
throw "Sorry, installing Cygwin is unsupported on $os"