mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-04 05:13:16 +08:00
Add more supports for tar extensions (#48)
* added test for extracting .tar.gz * added ability to extract .tar.xz * add flags to extract tar * make use of tempPath * check file contents and make different content for tar file
This commit is contained in:
committed by
Danny McCormick
parent
35cd59e8d5
commit
2c3e55b8c9
@@ -187,16 +187,21 @@ export async function extract7z(
|
||||
*
|
||||
* @param file path to the tar
|
||||
* @param dest destination directory. Optional.
|
||||
* @param flags flags for the tar. Optional.
|
||||
* @returns path to the destination directory
|
||||
*/
|
||||
export async function extractTar(file: string, dest?: string): Promise<string> {
|
||||
export async function extractTar(
|
||||
file: string,
|
||||
dest?: string,
|
||||
flags: string = 'xz'
|
||||
): Promise<string> {
|
||||
if (!file) {
|
||||
throw new Error("parameter 'file' is required")
|
||||
}
|
||||
|
||||
dest = dest || (await _createExtractFolder(dest))
|
||||
const tarPath: string = await io.which('tar', true)
|
||||
await exec(`"${tarPath}"`, ['xzC', dest, '-f', file])
|
||||
await exec(`"${tarPath}"`, [flags, '-C', dest, '-f', file])
|
||||
|
||||
return dest
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user