From afbc5c0a9e6a290c6b2c574193af2c9f56da4413 Mon Sep 17 00:00:00 2001 From: Sampark Sharma Date: Wed, 30 Nov 2022 06:16:19 +0000 Subject: [PATCH] Add await to async function calls --- packages/cache/src/internal/tar.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/cache/src/internal/tar.ts b/packages/cache/src/internal/tar.ts index f9f91d15..db05a9e5 100644 --- a/packages/cache/src/internal/tar.ts +++ b/packages/cache/src/internal/tar.ts @@ -240,7 +240,11 @@ export async function listTar( compressionMethod: CompressionMethod ): Promise { const args = await getArgs(compressionMethod, 'list', archivePath) - exec(args) + try { + await exec(args) + } catch (error) { + throw new Error(`Tar failed with error: ${error?.message}`) + } } export async function extractTar( @@ -251,7 +255,11 @@ export async function extractTar( const workingDirectory = getWorkingDirectory() await io.mkdirP(workingDirectory) const args = await getArgs(compressionMethod, 'extract', archivePath) - exec(args) + try { + await exec(args) + } catch (error) { + throw new Error(`Tar failed with error: ${error?.message}`) + } } export async function createTar( @@ -265,5 +273,9 @@ export async function createTar( sourceDirectories.join('\n') ) const args = await getArgs(compressionMethod, 'create') - await exec(args, undefined, {cwd: archiveFolder}) + try { + await exec(args, undefined, {cwd: archiveFolder}) + } catch (error) { + throw new Error(`Tar failed with error: ${error?.message}`) + } }