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 *