Skip to content

Commit

Permalink
test: fix regression testing action
Browse files Browse the repository at this point in the history
Co-authored-by: strarsis <[email protected]>
Co-authored-by: Bogdan Chadkin <[email protected]>
Signed-off-by: Seth Falco <[email protected]>
  • Loading branch information
3 people committed Sep 22, 2023
1 parent 73f7002 commit 7c5e72a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
"name": "Bogdan Chadkin",
"email": "[email protected]",
"url": "https://github.com/TrySound"
},
{
"name": "Seth Falco",
"email": "[email protected]",
"url": "https://falco.fun/"
}
],
"repository": {
Expand Down
12 changes: 8 additions & 4 deletions test/regression-extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ const path = require('path');
const util = require('util');
const zlib = require('zlib');
const stream = require('stream');
const fetch = require('node-fetch');
const { default: fetch } = require('node-fetch');
const tarStream = require('tar-stream');

const pipeline = util.promisify(stream.pipeline);

/**
* @param {string} url
* @param {string} baseDir
* @param {RegExp} include
*/
const extractTarGz = async (url, baseDir, include) => {
const extract = tarStream.extract();
extract.on('entry', async (header, stream, next) => {
Expand All @@ -19,8 +24,7 @@ const extractTarGz = async (url, baseDir, include) => {
const file = path.join(baseDir, header.name);
await fs.promises.mkdir(path.dirname(file), { recursive: true });
await pipeline(stream, fs.createWriteStream(file));
}
if (header.name.endsWith('.svgz')) {
} else if (header.name.endsWith('.svgz')) {
// .svgz -> .svg
const file = path.join(baseDir, header.name.slice(0, -1));
await fs.promises.mkdir(path.dirname(file), { recursive: true });
Expand All @@ -39,7 +43,7 @@ const extractTarGz = async (url, baseDir, include) => {
next();
});
const response = await fetch(url);
await pipeline(response.body, extract);
await pipeline(response.body, zlib.createGunzip(), extract);
};

(async () => {
Expand Down

0 comments on commit 7c5e72a

Please sign in to comment.