Files
n8n-nodes-gwezz-changdunovel/node_modules/release-it/test/util/fetch.js
2025-10-26 23:10:15 +08:00

33 lines
655 B
JavaScript

import { Readable } from 'node:stream';
import { create as createTar } from 'tar';
import { appendFile, mkTmpDir } from './helpers.js';
export function createTarBlob(dir) {
const stream = new Readable({
read() {}
});
createTar(
{
gzip: true,
portable: true,
sync: false,
cwd: dir
},
['.']
)
.on('data', chunk => stream.push(chunk))
.on('end', () => stream.push(null));
return stream;
}
export function createTarBlobByRawContents(contents) {
const dir = mkTmpDir();
for (const [key, value] of Object.entries(contents)) {
appendFile(value, key, dir);
}
return createTarBlob(dir);
}