1
0
Fork 0

Support for extracting xar compatible archives

pull/207/head
Frederik Wallner 2019-11-08 09:37:56 +01:00
parent ca65f538e9
commit 08fed982a7
No known key found for this signature in database
GPG Key ID: AB5A2354F2F8FDC3
1 changed files with 24 additions and 0 deletions

View File

@ -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<string> {
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
*