diff --git a/src/download.ts b/src/download.ts new file mode 100644 index 00000000..8fa2c4f9 --- /dev/null +++ b/src/download.ts @@ -0,0 +1,13 @@ +import { createWriteStream } from 'node:fs'; +import { argv } from 'node:process'; +import { Readable } from 'node:stream'; +import { finished } from 'node:stream/promises'; + +const url = argv[2]; +const targetFile = argv[3]; + +console.log(`Downloading ${url} to ${targetFile}`); + +const file = createWriteStream(targetFile); +const { body } = await fetch(url); +await finished(Readable.fromWeb(body).pipe(file));