From 84eaf929144e40e16784ce145e6640736215a016 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 24 Dec 2020 21:55:54 +0300 Subject: use well-known path to choco.exe if not in PATH --- action.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'action.yml') 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" -- cgit v1.2.3