Skip to content

Commit

Permalink
fix framework download
Browse files Browse the repository at this point in the history
  • Loading branch information
ronny1982 committed Apr 21, 2024
1 parent 6fcfef1 commit 9a4326b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/tools.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import path from 'node:path';
import fs from 'node:fs/promises';
import { Readable } from 'node:stream';
import stream from 'node:stream/promises';
import { exec } from 'node:child_process';

/**
Expand All @@ -26,13 +28,11 @@ export async function purge(directory) {
export async function download(source, target) {
const response = await fetch(source);
const file = await fs.open(target, 'w', 0o755);
const stream = file.createWriteStream(target, { highWaterMark: 262144 });
const filestream = file.createWriteStream(target, { highWaterMark: 262144 });
try {
await new Promise((resolve, reject) => {
response.body.pipe(stream, { end: true }).on('finish', resolve).on('error', reject);
});
await stream.finished(Readable.fromWeb(response.body).pipe(filestream));
} finally {
stream.close();
filestream.close();
}
}

Expand Down

0 comments on commit 9a4326b

Please sign in to comment.