From 34f71e80ce5cc78c5b28f301914b9a9e16af43c5 Mon Sep 17 00:00:00 2001 From: Reinier Timmer Date: Tue, 28 Apr 2020 16:36:49 +0200 Subject: [PATCH] Check if tool path exists before executing (#385) --- packages/tool-cache/__tests__/tool-cache.test.ts | 6 +++--- packages/tool-cache/src/tool-cache.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/tool-cache/__tests__/tool-cache.test.ts b/packages/tool-cache/__tests__/tool-cache.test.ts index 42a3e4ea..f3718327 100644 --- a/packages/tool-cache/__tests__/tool-cache.test.ts +++ b/packages/tool-cache/__tests__/tool-cache.test.ts @@ -461,7 +461,7 @@ describe('@actions/tool-cache', function() { ] await exec.exec(`"${powershellPath}"`, args) } else { - const zipPath: string = await io.which('zip') + const zipPath: string = await io.which('zip', true) await exec.exec(`"${zipPath}`, [zipFile, '-r', '.'], {cwd: stagingDir}) } @@ -512,7 +512,7 @@ describe('@actions/tool-cache', function() { ] await exec.exec(`"${powershellPath}"`, args) } else { - const zipPath: string = await io.which('zip') + const zipPath: string = await io.which('zip', true) await exec.exec(zipPath, [zipFile, '-r', '.'], {cwd: stagingDir}) } @@ -569,7 +569,7 @@ describe('@actions/tool-cache', function() { ] await exec.exec(`"${powershellPath}"`, args) } else { - const zipPath: string = await io.which('zip') + const zipPath: string = await io.which('zip', true) await exec.exec(zipPath, [zipFile, '-r', '.'], {cwd: stagingDir}) } diff --git a/packages/tool-cache/src/tool-cache.ts b/packages/tool-cache/src/tool-cache.ts index ea2b9036..f43f8b51 100644 --- a/packages/tool-cache/src/tool-cache.ts +++ b/packages/tool-cache/src/tool-cache.ts @@ -279,7 +279,7 @@ async function extractZipWin(file: string, dest: string): Promise { const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')` // run powershell - const powershellPath = await io.which('powershell') + const powershellPath = await io.which('powershell', true) const args = [ '-NoLogo', '-Sta', @@ -294,7 +294,7 @@ async function extractZipWin(file: string, dest: string): Promise { } async function extractZipNix(file: string, dest: string): Promise { - const unzipPath = await io.which('unzip') + const unzipPath = await io.which('unzip', true) await exec(`"${unzipPath}"`, [file], {cwd: dest}) }