Support for extracting xar compatible archives

This commit is contained in:
Frederik Wallner
2019-11-08 09:37:56 +01:00
parent ca65f538e9
commit 08fed982a7
+24
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
*