Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

github-files-fetcher

Gyumeijie2.1kMIT1.6.0

download files from github repository

github, repo, repository, download, fetch, fetcher, files

readme

Introduction License: MIT

The github-files-fetcher is mainly designed for downloading part file(s) from a github repository. This is very useful if you have a low bandwidth network and/or just need particular file(s) or subdirectory from a large repository. While you want to download the whole repository, the git clone command is preferred.

Installation

Run npm install -g github-files-fetcher

Basic usage

fetcher --url=resource_url  --out=output_directory

For example:

fetcher --url="https://github.com/Gyumeijie/github-files-fetcher/blob/master/CHANGELOG.md" --out=/tmp

Authentication

The default unauthorized API access rate is 60 times per hour, and usually this is enough. When the access rate exceeded, you can still achieve higher access rate by authentication, which can be done in the following three ways:

  1. The --auth commandline option

This option take the form of --auth=username:password, where the password can be either the login password for your github account or the personal access token which can be generated in https://github.com/settings/tokens.

  1. Default configuration file

The default configuration file is ~/.download_github, and the config file is a json file.

  1. Designate via --file commandline option

For example, you can have the ~/config.json be the configuration file.

 # download a directory
 fetcher --file="~/config.json" --url="https://github.com/reduxjs/redux/tree/master/examples/async" --out="~/" 

 # download a single file
 fetcher --file="~/config.json" --url="https://github.com/Gyumeijie/github-files-fetcher/blob/master/index.js" --out="~/" 

The following is the template of the configuration file:

{
   "auth": {
        "username" : "your_github_name",
        "password" : "password_or_api_access_token"
   },
   "alwaysUseAuth" : true,
   "timeout" : 5000 
}

When the default unauthorized API access rate exceeded, the github-files-fetcher will automatically switch to use authentication if one is provided through the three ways above.

Since the github-files-fetcher request resource without authentication in default for performance consideration, and switch to use authentication if necessary, this causes unnecessary cost once the default unauthorized API access rate exceeded. To avoid this problem you can have the github-files-fetcher always use authentication by specify --alwaysUseAuth option.

Environment

node >= 6

Related works

There are some other good tools that can do the same thing for you:

changelog

1.2.0 (2018-09-18)

Bug Fixes

Features

  • add --alwaysUseAuth option (f8ea220)
  • add --file option (01e6a77)
  • add --help option (a64a3b0)
  • add auth status in progroess bar (e60b4f8)
  • add event listener for CTRL+C (2b2441d)
  • add progress bar (d983874)
  • add support for alwaysUseAuth in config file (f3eda1b)
  • finish basic features. (d7aace5)
  • finish parsing the repo url (6ea892c)
  • support command line authentication (16126b3)
  • support commondline args (5a8cb3e)

Performance Improvements

  • support request with or without auth (25b98c6)