|
|
@ -1,7 +1,18 @@
|
|
|
|
import { exec } from "@actions/exec";
|
|
|
|
import { exec } from "@actions/exec";
|
|
|
|
import * as io from "@actions/io";
|
|
|
|
import * as io from "@actions/io";
|
|
|
|
|
|
|
|
|
|
|
|
export async function extractTar(archivePath: string, targetDirectory: string) {
|
|
|
|
async function getTarPath(): Promise<string> {
|
|
|
|
|
|
|
|
// Explicitly use BSD Tar on Windows
|
|
|
|
|
|
|
|
const IS_WINDOWS = process.platform === "win32";
|
|
|
|
|
|
|
|
return IS_WINDOWS
|
|
|
|
|
|
|
|
? `${process.env["windir"]}\\System32\\tar.exe`
|
|
|
|
|
|
|
|
: await io.which("tar", true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export async function extractTar(
|
|
|
|
|
|
|
|
archivePath: string,
|
|
|
|
|
|
|
|
targetDirectory: string
|
|
|
|
|
|
|
|
): Promise<void> {
|
|
|
|
// Create directory to extract tar into
|
|
|
|
// Create directory to extract tar into
|
|
|
|
await io.mkdirP(targetDirectory);
|
|
|
|
await io.mkdirP(targetDirectory);
|
|
|
|
|
|
|
|
|
|
|
@ -11,17 +22,12 @@ export async function extractTar(archivePath: string, targetDirectory: string) {
|
|
|
|
await exec(`"${await getTarPath()}"`, args);
|
|
|
|
await exec(`"${await getTarPath()}"`, args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export async function createTar(archivePath: string, sourceDirectory: string) {
|
|
|
|
export async function createTar(
|
|
|
|
|
|
|
|
archivePath: string,
|
|
|
|
|
|
|
|
sourceDirectory: string
|
|
|
|
|
|
|
|
): Promise<void> {
|
|
|
|
// http://man7.org/linux/man-pages/man1/tar.1.html
|
|
|
|
// http://man7.org/linux/man-pages/man1/tar.1.html
|
|
|
|
// tar [-options] <name of the tar archive> [files or directories which to add into archive]
|
|
|
|
// tar [-options] <name of the tar archive> [files or directories which to add into archive]
|
|
|
|
const args = ["-cz", "-f", archivePath, "-C", sourceDirectory, "."];
|
|
|
|
const args = ["-cz", "-f", archivePath, "-C", sourceDirectory, "."];
|
|
|
|
await exec(`"${await getTarPath()}"`, args);
|
|
|
|
await exec(`"${await getTarPath()}"`, args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async function getTarPath(): Promise<string> {
|
|
|
|
|
|
|
|
// Explicitly use BSD Tar on Windows
|
|
|
|
|
|
|
|
const IS_WINDOWS = process.platform === "win32";
|
|
|
|
|
|
|
|
return IS_WINDOWS
|
|
|
|
|
|
|
|
? `${process.env["windir"]}\\System32\\tar.exe`
|
|
|
|
|
|
|
|
: await io.which("tar", true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|