microlinkhq / youtube-dl-exec

A simple Node.js wrapper for youtube-dl/yt-dlp.
MIT License
423 stars 75 forks source link

feat!: rewrite the postinstall script #192

Closed miraclx closed 6 months ago

miraclx commented 6 months ago

Branched off #191

Swaps out simple-get for fetch, and uses streams instead of buffering the whole binary in memory.

$  DEBUG=youtube-dl-exec* node ./scripts/postinstall.js   
  youtube-dl-exec:install downloading url=https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
  youtube-dl-exec:install writing path=/git/microlinkhq/youtube-dl-exec/bin/yt-dlp
  youtube-dl-exec:install status=success

Tested with npm, yarn and pnpm, and they all hide std{out,err} logs from post-install scripts on install unless the run fails. You can confirm this as well.

Kikobeats commented 6 months ago

Thanks for this @miraclx.

I modified your code for using debug-logfmt instead of log since it could be controlled via environment variable (added into docs too).

Also I noted we can drop a filesystem operation so I implemented the changes and dropped some unnecessary lines to make the script easier to maintain 🙂