Skip to content

Commit

Permalink
Add support for .tar.zst
Browse files Browse the repository at this point in the history
  • Loading branch information
xingrz committed Nov 2, 2021
1 parent 84a8c10 commit e7bb6c7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
Binary file added fixtures/file.tar.zst
Binary file not shown.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const fs = require('graceful-fs');
const decompressTar = require('decompress-tar');
const decompressTarbz2 = require('decompress-tarbz2');
const decompressTargz = require('decompress-targz');
const decompressTarzst = require('@xingrz/decompress-tarzst');
const decompressUnzip = require('decompress-unzip');
const makeDir = require('make-dir');
const pify = require('pify');
Expand Down Expand Up @@ -142,6 +143,7 @@ module.exports = (input, output, opts) => {
decompressTar(),
decompressTarbz2(),
decompressTargz(),
decompressTarzst(),
decompressUnzip()
]}, opts);

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
"tar",
"tar.bz",
"tar.gz",
"tar.zst",
"zip",
"unzip"
],
"dependencies": {
"@xingrz/decompress-tarzst": "^1.2.0",
"decompress-tar": "^4.0.0",
"decompress-tarbz2": "^4.0.0",
"decompress-targz": "^4.0.0",
Expand Down
6 changes: 6 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ test('extract file', async t => {
const tarFiles = await m(path.join(__dirname, 'fixtures', 'file.tar'));
const tarbzFiles = await m(path.join(__dirname, 'fixtures', 'file.tar.bz2'));
const targzFiles = await m(path.join(__dirname, 'fixtures', 'file.tar.gz'));
const tarzstFiles = await m(path.join(__dirname, 'fixtures', 'file.tar.zst'));
const zipFiles = await m(path.join(__dirname, 'fixtures', 'file.zip'));

t.is(tarFiles[0].path, 'test.jpg');
Expand All @@ -32,6 +33,8 @@ test('extract file', async t => {
t.true(isJpg(tarbzFiles[0].data));
t.is(targzFiles[0].path, 'test.jpg');
t.true(isJpg(targzFiles[0].data));
t.is(tarzstFiles[0].path, 'test.jpg');
t.true(isJpg(tarzstFiles[0].data));
t.is(zipFiles[0].path, 'test.jpg');
t.true(isJpg(zipFiles[0].data));
});
Expand All @@ -43,12 +46,15 @@ test('extract file using buffer', async t => {
const tarbzFiles = await m(tarbzBuf);
const targzBuf = await fsP.readFile(path.join(__dirname, 'fixtures', 'file.tar.gz'));
const targzFiles = await m(targzBuf);
const tarzstBuf = await fsP.readFile(path.join(__dirname, 'fixtures', 'file.tar.zst'));
const tarzstFiles = await m(tarzstBuf);
const zipBuf = await fsP.readFile(path.join(__dirname, 'fixtures', 'file.zip'));
const zipFiles = await m(zipBuf);

t.is(tarFiles[0].path, 'test.jpg');
t.is(tarbzFiles[0].path, 'test.jpg');
t.is(targzFiles[0].path, 'test.jpg');
t.is(tarzstFiles[0].path, 'test.jpg');
t.is(zipFiles[0].path, 'test.jpg');
});

Expand Down

0 comments on commit e7bb6c7

Please sign in to comment.