Repository navigation
Conversation
Add an experimental tar reader to node:zlib, ported from fast-tar: listTar(), extractTar(), createTarExtractStream(), tarEntries(), their synchronous variants, and the TarParser they are built on. Signed-off-by: Matteo Collina <hello@matteocollina.com>
Add TarEntry.create(), createStream(), createSymlink() and createLink(), and createTarArchive(), createTarArchiveSync() and tarFiles() to write them, mirroring the ZIP creation API. Signed-off-by: Matteo Collina <hello@matteocollina.com>
This comment was marked as resolved.
This comment was marked as resolved.
|
Not public, and it does not need to be, sorry for the mistake. |
|
@nodejs/tsc this is a big PR and it needs your approval. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #67975 +/- ##
==========================================
+ Coverage 90.53% 90.64% +0.11%
==========================================
Files 805 817 +12
Lines 285915 291978 +6063
Branches 55213 56746 +1533
==========================================
+ Hits 258841 264655 +5814
- Misses 17186 17390 +204
- Partials 9888 9933 +45
🚀 New features to boost your workflow:
|
|
Have you read https://astral.sh/blog/tar-codec? It's a good overview of some of the pitfalls with tar parsing, and they have tests you could borrow. There's also this other large test suite. It recommends a policy of rejecting ambiguities in tar files that could make implementations extract different files, which I'd love to see node follow. (Alternatively, you could compile tar-codec to wasm and use that, instead of writing and maintaining your own. That approach has much to recommend it.) Edit: also I note that you added support for extracting to disk, which the zip support deliberately omitted. Nothing inherently wrong with that but a little odd for them to be asymmetric, and there's many more pitfalls when extracting rather than merely reading. |
Adds experimental tar support to
node:zlib, next to the ZIP API: reading (listTar(),extractTar(),createTarExtractStream(),tarEntries(),TarParser) and writing (TarEntry.create*(),createTarArchive(),tarFiles()), with sync variants.tar is the basis of npm: every package is a tarball, so every install unpacks them and every publish creates one. Having it in core benefits the whole ecosystem.
The API is compatible with the one of node-tar: the extraction options (
cwd,strip,filter,preservePaths,preserveOwner,onwarn, ...) and the entry fields and type names are the same.AI generated, reviewed by me