Skip to content

Commit

Permalink
Added download.ts as helper for npm
Browse files Browse the repository at this point in the history
  • Loading branch information
smarr committed Jun 13, 2023
1 parent b4f7fbc commit acf30fa
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/download.ts
Original file line number Diff line number Diff line change
@@ -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(<any>body).pipe(file));

0 comments on commit acf30fa

Please sign in to comment.