cross-7zip - v1.2.0
    Preparing search index...

    Class SevenUnzip

    A wrapper class for extracting files from a 7-Zip archive using the command-line tool.

    import { SevenUnzip } from 'cross-7zip';

    function extractArchiveSync(): void {
    try {
    const sevenUnzip = new SevenUnzip({
    archive: 'example.7z',
    destination: 'outputFolder',
    password: 'secure 123'
    });

    sevenUnzip.runSync();
    console.log('Extraction completed successfully.');
    } catch (error) {
    console.error('An error occurred during extraction:', error);
    }
    }

    async function extractArchive(): Promise<void> {
    try {
    const sevenUnzip = new SevenUnzip()
    .setArchive('example.7z')
    .setDestination('outputFolder')
    .setPassword('secure 123');

    await sevenUnzip.run();
    console.log('Extraction completed successfully.');
    } catch (error) {
    console.error('An error occurred during extraction:', error);
    }
    }

    For additional examples, see the sevenZipUnzip.test.ts or sevenZipUnzipSync.test.ts.

    Index

    Constructors

    Accessors

    • get args(): string[]

      Generates the arguments for the 7-Zip command-line execution.

      Returns string[]

    • get command(): undefined | string

      Gets the path to the 7-Zip executable.

      Returns undefined | string

    Methods

    • Runs the extraction process asynchronously.

      Returns Promise<void>

      If the 7-Zip executable is not found.

    • Runs the extraction process synchronously.

      Returns void

      If the 7-Zip executable is not found.

    • Sets the archive file to extract.

      Parameters

      • archive: string

        The path to the archive file.

      Returns SevenUnzip

      The SevenUnzip instance for method chaining.

    • Sets the destination path for the extraction.

      Parameters

      • destination: string

        The path to the output folder.

      Returns SevenUnzip

      The SevenUnzip instance for method chaining.

    • Sets a password for extracting encrypted archives.

      Parameters

      • password: string

        The password string.

      Returns SevenUnzip

      The SevenUnzip instance for method chaining.

    • Returns a string representation of the 7-Zip command with its arguments.

      This method constructs the full command-line string that would be executed, ensuring that each argument is properly quoted to handle paths with spaces.

      Returns string

      The formatted command-line string.