diff --git a/__tests__/externals/zip-darwin b/__tests__/externals/zip-darwin new file mode 100755 index 0000000..60424b0 Binary files /dev/null and b/__tests__/externals/zip-darwin differ diff --git a/__tests__/tool-cache.test.ts b/__tests__/tool-cache.test.ts index c1fb9e8..59315e5 100644 --- a/__tests__/tool-cache.test.ts +++ b/__tests__/tool-cache.test.ts @@ -231,7 +231,9 @@ describe('@actions/tool-cache', function() { ] await exec.exec(`"${powershellPath}"`, args) } else { - const zipPath: string = path.join(__dirname, 'externals', 'zip') + const zipBin: string = + process.platform === 'darwin' ? 'zip-darwin' : 'zip' + const zipPath: string = path.join(__dirname, 'externals', zipBin) await exec.exec(`"${zipPath}`, [zipFile, '-r', '.'], {cwd: stagingDir}) } @@ -282,7 +284,9 @@ describe('@actions/tool-cache', function() { ] await exec.exec(`"${powershellPath}"`, args) } else { - const zipPath = path.join(__dirname, 'externals', 'zip') + const zipBin: string = + process.platform === 'darwin' ? 'zip-darwin' : 'zip' + const zipPath = path.join(__dirname, 'externals', zipBin) await exec.exec(zipPath, [zipFile, '-r', '.'], {cwd: stagingDir}) } diff --git a/scripts/externals/unzip-darwin b/scripts/externals/unzip-darwin new file mode 100755 index 0000000..4ef1504 Binary files /dev/null and b/scripts/externals/unzip-darwin differ diff --git a/src/tool-cache.ts b/src/tool-cache.ts index a25cdce..c4c71f1 100644 --- a/src/tool-cache.ts +++ b/src/tool-cache.ts @@ -218,7 +218,11 @@ export async function extractZip(file: string, dest?: string): Promise { if (IS_WINDOWS) { await extractZipWin(file, dest) } else { - await extractZipNix(file, dest) + if (process.platform === 'darwin') { + await extractZipDarwin(file, dest) + } else { + await extractZipNix(file, dest) + } } return dest @@ -250,6 +254,17 @@ async function extractZipNix(file: string, dest: string): Promise { await exec(`"${unzipPath}"`, [file], {cwd: dest}) } +async function extractZipDarwin(file: string, dest: string): Promise { + const unzipPath = path.join( + __dirname, + '..', + 'scripts', + 'externals', + 'unzip-darwin' + ) + await exec(`"${unzipPath}"`, [file], {cwd: dest}) +} + /** * Caches a directory and installs it into the tool cacheDir *