From 6bc5dc5a23f73476158e721ec19cae1e75e31e33 Mon Sep 17 00:00:00 2001 From: Sampark Sharma Date: Mon, 12 Dec 2022 07:25:36 +0000 Subject: [PATCH] Fix test --- packages/cache/__tests__/tar.test.ts | 2 +- packages/cache/src/internal/tar.ts | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/cache/__tests__/tar.test.ts b/packages/cache/__tests__/tar.test.ts index 3e837960..a6a79a3d 100644 --- a/packages/cache/__tests__/tar.test.ts +++ b/packages/cache/__tests__/tar.test.ts @@ -365,7 +365,7 @@ test('zstd list tar with windows BSDtar', async () => { await tar.listTar(archivePath, CompressionMethod.Zstd) const tarPath = SystemTarPathOnWindows - expect(execMock).toHaveBeenCalledTimes(1) + expect(execMock).toHaveBeenCalledTimes(2) expect(execMock).toHaveBeenNthCalledWith( 1, diff --git a/packages/cache/src/internal/tar.ts b/packages/cache/src/internal/tar.ts index 6d48e7b8..69731381 100644 --- a/packages/cache/src/internal/tar.ts +++ b/packages/cache/src/internal/tar.ts @@ -180,7 +180,7 @@ async function getDecompressionProgram( case CompressionMethod.Zstd: return BSD_TAR_ZSTD ? [ - 'zstd -d --long=30 -o', + 'zstd -d --long=30 --force -o', TarFilename, archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/') ] @@ -191,7 +191,7 @@ async function getDecompressionProgram( case CompressionMethod.ZstdWithoutLong: return BSD_TAR_ZSTD ? [ - 'zstd -d -o', + 'zstd -d --force -o', TarFilename, archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/') ] @@ -219,7 +219,7 @@ async function getCompressionProgram( case CompressionMethod.Zstd: return BSD_TAR_ZSTD ? [ - 'zstd -T0 --long=30 -o', + 'zstd -T0 --long=30 --force -o', cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), TarFilename ] @@ -230,7 +230,7 @@ async function getCompressionProgram( case CompressionMethod.ZstdWithoutLong: return BSD_TAR_ZSTD ? [ - 'zstd -T0 -o', + 'zstd -T0 --force -o', cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), TarFilename ] @@ -245,7 +245,9 @@ async function execCommands(commands: string[], cwd?: string): Promise { try { await exec(command, undefined, {cwd}) } catch (error) { - throw new Error(`${command[0]} failed with error: ${error?.message}`) + throw new Error( + `${command.split(' ')[0]} failed with error: ${error?.message}` + ) } } }