Skip to content

Repository files navigation

Download Github Release

A node module to download Github release assets. It will also uncompress zip files and skip downloading if a file already exists.

$ fetch-github-release -s darwin-x64 electron electron
Downloading electron/electron@v1.3.1...
electron-v1.3.1-darwi... ▇▇▇▇▇---------------------------------------------------- 662.8s
electron-v1.3.1-darwi... ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇--------- 13.4s
electron-v1.3.1-darwi... ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇--- 3.6s
ffmpeg-v1.3.1-darwin-... ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 0.0s

This is useful for instance if you have a project that depends on binaries released via Github.

Command line

Installation

npm install -g @terascope/fetch-github-release
# or
yarn global add @terascope/fetch-github-release

Usage

Usage: fetch-github-release [options] <user><repo> [outputdir]
Options:
-V, --version output the version number
-p, --prerelease download prerelease
-s, --search <regexp> filter assets name
-q, --quiet don't log to console -z, --zipped don't extract zip files
-h, --help output usage information

Example

Download electron/electron assets whose name contains darwin-x64 to /tmp.

fetch-github-release -s darwin-x64 electron electron /tmp

If you need to download assets from a private repository or you need to avoid rate limits, you can set the environment variable GITHUB_TOKEN. To generate a token go to your Github settings and a token with public_repo or repo (for private repos) permissions.

API

Installation

npm install --save @terascope/fetch-github-release
# or
yarn add @terascope/fetch-github-release

Usage

import{downloadRelease}from'@terascope/fetch-github-release';constuser='some user';constrepo='some repo';constoutputdir='some output directory';constleaveZipped=false;constdisableLogging=false;// Define a function to filter releases.functionfilterRelease(release){// Filter out prereleases.returnrelease.prerelease===false;}// Define a function to filter assets.functionfilterAsset(asset){// Select assets that contain the string 'windows'.returnasset.name.includes('windows');}downloadRelease(user,repo,outputdir,filterRelease,filterAsset,leaveZipped,disableLogging).then(function(){console.log('All done!');}).catch(function(err){console.error(err.message);});

downloadRelease returns an array of file paths to all of the files downloaded if called with leaveZipped = true.

TODO

  • other compression formats
  • option to download specific release instead of latest?
  • option to download source?

About

A NodeJS module to download Github release assets

Resources

Stars

25 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages