From e7bb6c752f914763d2479f38f2094c750f1e87a2 Mon Sep 17 00:00:00 2001 From: XiNGRZ Date: Tue, 2 Nov 2021 01:23:19 +0800 Subject: [PATCH] Add support for .tar.zst --- fixtures/file.tar.zst | Bin 0 -> 2148 bytes index.js | 2 ++ package.json | 2 ++ test.js | 6 ++++++ 4 files changed, 10 insertions(+) create mode 100644 fixtures/file.tar.zst diff --git a/fixtures/file.tar.zst b/fixtures/file.tar.zst new file mode 100644 index 0000000000000000000000000000000000000000..94d780730f9e7cb821eadbcd7d599644f6fd52c7 GIT binary patch literal 2148 zcmV-q2%GmPwJ-eyh`mAplz?<)b963haAyE8HZ(LbH#IOcGchm#F)}hRG&M0bF)=kY zG5{bj0CjV8VR9fK0BdD-c47b6|KI=+N=8XW0099200962+W>?B4G9Vh3J47g3JVSn z4G$9_6%!H?6DJ%V7a%SvF)%JEEi5xSNNfz z0S*oh6A=?86%{5=H7zwy|G)qd2mnCfx-R##YAT4Q8oW@l(=YIAgTc6WGrdV_?8 zhKGoWijtF*m6n&7nVO=bq@|{(sHv*5v$VCgx45~w!o$SH#>dFX%F@%+)z;V8+1laa z0|5~N1Ox*F2X_$!1tBp85(F6+t5v5{2X;RrjQ8p9RzQqC zQ%wnsBB+xqQP%A&ZUhavR_WZqt7thE zlVU`oJdV_^RgVtw0LO^6G5-Kha{mD6X1Qg%J0tL;+EBZkx8+1>zN{rt6!rUgE;M-z zITJ)f#=zjI2mC7K7i|cHla{ADr1;U{m{{ttODX%QEK9k@J23C{6rod1M^cu$8d{Hw zZS4lwtS;VW`->ukT=vg7s&!E+gJ&Zx(o1zCTuQAeY&jjs&VO9jB~4D+S~QPJ)4aJf z+h&ZNhB3E3mEBF=DD!HoO_tFYaRV70Ks<_k*B32`02B_#gm{boMom-xza{?w(9Ltb z&Zz85*7!cScZMF3MN(KiZ^5e>Jz2488vV6F{AHw<(u! zte-MX-=X4}oTQ$+9)qFyjj#0RG`l!OwfT=?Nh5yj06B1avG%Rhw6V=PX-k>x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+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'); @@ -142,6 +143,7 @@ module.exports = (input, output, opts) => { decompressTar(), decompressTarbz2(), decompressTargz(), + decompressTarzst(), decompressUnzip() ]}, opts); diff --git a/package.json b/package.json index d6133a8..aecc274 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test.js b/test.js index ba99d68..363fccc 100644 --- a/test.js +++ b/test.js @@ -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'); @@ -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)); }); @@ -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'); });