github-files-fetcher

1.6.0 • Public • Published

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:

Package Sidebar

Install

npm i github-files-fetcher

Weekly Downloads

654

Version

1.6.0

License

MIT

Unpacked Size

258 kB

Total Files

4

Last publish

Collaborators

  • gyumeijie