Skip to content

Commit

Permalink
Check if tool path exists before executing
Browse files Browse the repository at this point in the history
  • Loading branch information
reiniertimmer committed Mar 18, 2020
1 parent 12f3011 commit 54becc6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/tool-cache/__tests__/tool-cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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})
}

Expand Down Expand Up @@ -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})
}

Expand Down Expand Up @@ -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})
}

Expand Down
4 changes: 2 additions & 2 deletions packages/tool-cache/src/tool-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ async function extractZipWin(file: string, dest: string): Promise<void> {
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',
Expand All @@ -294,7 +294,7 @@ async function extractZipWin(file: string, dest: string): Promise<void> {
}

async function extractZipNix(file: string, dest: string): Promise<void> {
const unzipPath = await io.which('unzip')
const unzipPath = await io.which('unzip', true)
await exec(`"${unzipPath}"`, [file], {cwd: dest})
}

Expand Down

0 comments on commit 54becc6

Please sign in to comment.