Skip to content

[std] Add utility to decompress plain .gz files #1012

@kylewlacy

Description

@kylewlacy

This topic came up in another issue: #336 (comment)

Today, we have an unarchive method, which supports unarchiving .tar, .tar.gz, .tar.bz2, .tar.xz, .tar.zstd, and .zip files. In the aforementioned issue, we saw a case where, for Deno, we wanted to decompress a plain .gz file-- not an archive.

To resolve it, we manually decompressed the .gz file using std.runBash and the zcat utility:

std
  .download({
    url: "https://github.com/denoland/rusty_v8/releases/download/v135.1.0/librusty_v8_release_x86_64-unknown-linux-gnu.a.gz",
    hash: std.sha256Hash(
      "406a453645473bd8f8b9a818342e57dc95627fcd1155ace9eb7a2aadd5985285",
    ),
  })
  .pipe((gzip) =>
    std.runBash`
      zcat "$gzip" > "$BRIOCHE_OUTPUT"
    `
      .env({ gzip })
      .toFile(),
  );

We should provide a built-in way to go from a .gz file to the raw decompressed form as a utility within std. Just like with the existing .unarchive() method, we should also make sure it takes the compression format as an input, so we could add more compression formats over time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions