or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

caching.mddiscovery.mddownload.mdextraction.mdindex.mdmanifest.mdversions.md
tile.json

extraction.mddocs/

Archive Extraction

Cross-platform archive extraction supporting multiple formats including ZIP, tar with various compression schemes, 7z, and XAR for comprehensive tool setup workflows.

Capabilities

ZIP Extraction

Extracts ZIP compressed files to a specified or auto-generated directory.

/**
 * Extracts a ZIP compressed file
 * @param file - Path to the ZIP file to extract
 * @param dest - Optional destination directory (auto-generated if not provided)
 * @returns Promise resolving to the path of the extracted directory
 */
function extractZip(file: string, dest?: string): Promise<string>;

Usage Examples:

import { extractZip } from "@actions/tool-cache";

// Basic ZIP extraction
const extractedPath = await extractZip("/path/to/tool.zip");

// Extract to specific directory
const extractedPath = await extractZip("/path/to/tool.zip", "/opt/myapp");

Tar Archive Extraction

Extracts tar compressed files with support for various compression formats (gz, bz2, xz).

/**
 * Extracts a tar compressed file with optional compression
 * @param file - Path to the tar file to extract
 * @param dest - Optional destination directory (auto-generated if not provided)
 * @param flags - Optional tar extraction flags (string or array of strings)
 * @returns Promise resolving to the path of the extracted directory
 */
function extractTar(
  file: string,
  dest?: string,
  flags?: string | string[]
): Promise<string>;

Usage Examples:

import { extractTar } from "@actions/tool-cache";

// Basic tar extraction (auto-detects compression)
const extractedPath = await extractTar("/path/to/tool.tar.gz");

// Extract with custom flags
const extractedPath = await extractTar(
  "/path/to/tool.tar.bz2",
  "/opt/myapp",
  ["--strip-components=1"]
);

// Extract with single flag
const extractedPath = await extractTar(
  "/path/to/tool.tar.xz",
  undefined,
  "--strip-components=1"
);

7z Archive Extraction

Extracts 7z compressed files with optional custom 7z executable path. Windows only.

/**
 * Extracts a 7z compressed file (Windows only)
 * @param file - Path to the 7z file to extract
 * @param dest - Optional destination directory (auto-generated if not provided)
 * @param _7zPath - Optional path to 7z executable (uses system 7z if not provided)
 * @returns Promise resolving to the path of the extracted directory
 * @throws Error if called on non-Windows platforms
 */
function extract7z(
  file: string,
  dest?: string,
  _7zPath?: string
): Promise<string>;

Usage Examples:

import { extract7z } from "@actions/tool-cache";

// Basic 7z extraction
const extractedPath = await extract7z("/path/to/tool.7z");

// Extract to specific directory
const extractedPath = await extract7z("/path/to/tool.7z", "/opt/myapp");

// Use custom 7z executable
const extractedPath = await extract7z(
  "/path/to/tool.7z",
  "/opt/myapp",
  "/usr/local/bin/7z"
);

XAR Archive Extraction

Extracts XAR compressed files (commonly used for macOS .pkg files) with optional flags.

/**
 * Extracts a XAR compressed file (macOS .pkg files)
 * @param file - Path to the XAR file to extract
 * @param dest - Optional destination directory (auto-generated if not provided)
 * @param flags - Optional xar extraction flags (string or array of strings)
 * @returns Promise resolving to the path of the extracted directory
 */
function extractXar(
  file: string,
  dest?: string,
  flags?: string | string[]
): Promise<string>;

Usage Examples:

import { extractXar } from "@actions/tool-cache";

// Basic XAR extraction
const extractedPath = await extractXar("/path/to/installer.pkg");

// Extract with custom flags
const extractedPath = await extractXar(
  "/path/to/installer.pkg",
  "/opt/myapp",
  ["-x"]
);

// Extract with single flag
const extractedPath = await extractXar(
  "/path/to/installer.pkg",
  undefined,
  "-x"
);

Platform Support

Windows

  • ZIP: Native support
  • 7z: Supported (requires 7z executable or bundled 7zr.exe)
  • tar: Limited support (depends on system)
  • XAR: Not supported

macOS

  • ZIP: Native support
  • tar: Native support with all compression formats
  • 7z: Not supported (function throws error on non-Windows platforms)
  • XAR: Native support (primary format for .pkg files)

Linux

  • ZIP: Native support
  • tar: Native support with all compression formats
  • 7z: Not supported (function throws error on non-Windows platforms)
  • XAR: Limited support (requires xar package)

Implementation Details

Automatic Compression Detection

  • tar files: Automatically detects .gz, .bz2, .xz compression based on file extension
  • Destination handling: Auto-generates unique directories in temp folder if not specified
  • Error handling: Throws descriptive errors for missing files, invalid archives, or extraction failures

Flag Handling

  • String flags: Single flag as string (e.g., "--strip-components=1")
  • Array flags: Multiple flags as array (e.g., ["--strip-components=1", "--verbose"])
  • Platform compatibility: Flags are passed directly to underlying extraction tools

Directory Structure

  • Preserved structure: Maintains original archive directory structure by default
  • Custom extraction: Use flags like --strip-components to modify structure
  • Permissions: Preserves file permissions where supported by platform