From 08fed982a7243ba3bc14605783599c10fca9b525 Mon Sep 17 00:00:00 2001 From: Frederik Wallner Date: Fri, 8 Nov 2019 09:37:56 +0100 Subject: [PATCH] Support for extracting xar compatible archives --- packages/tool-cache/src/tool-cache.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/tool-cache/src/tool-cache.ts b/packages/tool-cache/src/tool-cache.ts index 9ab2deb5..6d802767 100644 --- a/packages/tool-cache/src/tool-cache.ts +++ b/packages/tool-cache/src/tool-cache.ts @@ -206,6 +206,30 @@ export async function extractTar( return dest } +/** + * Extract a xar compatible archive + * + * @param file path to the archive + * @param dest destination directory. Optional. + * @param flags flags for the xar. Optional. + * @returns path to the destination directory + */ +export async function extractXar( + file: string, + dest?: string, + flags: string = '-x' +): Promise { + if (!file) { + throw new Error("parameter 'file' is required") + } + + dest = dest || (await _createExtractFolder(dest)) + const xarPath: string = await io.which('xar', true) + await exec(`"${xarPath}"`, [flags, '-C', dest, '-f', file]) + + return dest +} + /** * Extract a zip *