# github-download-parts

> Download a partial folder of your Github repository.

Latest version **2.1.0** (published 2018-09-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install github-download-parts
pnpm add github-download-parts
yarn add github-download-parts
bun add github-download-parts
```

Provides the command `repo`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2018-09-18 |
| First published | 2017-10-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 8.0.0 |
| Dependencies | 5 |
| Unpacked size | 33 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | pspgbhu |
| Maintainers | pspgbhu |

## Links

- npm: https://www.npmjs.com/package/github-download-parts
- Repository: https://github.com/pspgbhu/github-download-parts
- Homepage: https://github.com/pspgbhu/github-download-parts#readme
- Issues: https://github.com/pspgbhu/github-download-parts/issues
- npm.io page: https://npm.io/package/github-download-parts

## Dependencies (5)

- [ora](https://npm.io/package/ora.md) ^3.0.0
- [chalk](https://npm.io/package/chalk.md) ^2.4.1
- [debug](https://npm.io/package/debug.md) ^3.1.0
- [request](https://npm.io/package/request.md) ^2.88.0
- [commander](https://npm.io/package/commander.md) ^2.18.0

## Recent versions

- 2.1.0 (latest) — 2018-09-18
- 2.0.3 — 2018-09-17
- 2.0.2 — 2018-09-17
- 2.0.1 — 2018-09-17
- 2.0.0 — 2018-09-10
- 1.0.1 — 2018-08-06
- 1.0.0 — 2018-08-06
- 0.1.6 — 2017-12-13
- 0.1.5 — 2017-12-01
- 0.1.4 — 2017-12-01
- 0.1.3 — 2017-12-01
- 0.1.2 — 2017-12-01
- 0.1.1 — 2017-12-01
- 0.1.0 — 2017-12-01
- 0.0.1 — 2017-10-13

## README

English | [简体中文](./README_CN.md)

# github-download-parts

[![npm package](https://img.shields.io/npm/v/github-download-parts.svg)](https://www.npmjs.org/package/github-download-parts)
[![NPM downloads](http://img.shields.io/npm/dm/github-download-parts.svg)](https://npmjs.org/package/github-download-parts)
[![GitHub issues](https://img.shields.io/github/issues/pspgbhu/github-download-parts.svg)](https://github.com/pspgbhu/github-download-parts/issues)
[![Build Status](https://travis-ci.org/pspgbhu/github-download-parts.svg?branch=master)](https://travis-ci.org/pspgbhu/github-download-parts)

It is able to download a partial of repository!


## Usage

- Download a single file

```js
const repo = require('github-download-parts');

// download the `index.js` file to `target` folder
repo('pspgbhu/github-download-parts', 'target', 'index.js')
  .then(() => {
    console.log('download success');
  })
  .catch(() => {
    console.log('download error');
  }
```

- Download a folder

```js
const repo = require('github-download-parts');

// download all files in the `test` folder of github repository to the local `target` folder.
repo('pspgbhu/github-download-parts', 'target', 'test')
  .then(() => {
    console.log('download success');
  })
  .catch(() => {
    console.log('download error');
  });
```

- Download a whole repository

```js
const repo = require('github-download-parts');

// download the whole repository into target local folder
repo('pspgbhu/github-download-parts', 'target')
  .then(() => {
    console.log('download success');
  })
  .catch(() => {
    console.log('download error');
  });
```

## API

### repo(options [, target ,pathname])

- **options** `<string>`

  Could input a string as the options, the format is `"${username}/${repository}"`.

- **target** `<string>`

  The local folder path that files will be created into.

- **pathname** `<string>`

  A file or folder path of github repository.

Or you could use a object as the `options` parameter

- **options** `<object>`
  - **username** `<string>`: The username of github.
  - **repository** `<string>`: The name of the repository.
  - **repo** `<string>`: The shorthand for `username` and `repository`, the format is `"${username}/${respository}"`
  - **target** `<string>`: The local folder path that files will be created into.
  - **pathname** `<string>`: A file or folder path of github repository.

## CLI

### Install

```bash
# Install the package
$ npm i -g github-download-parts

# Show more information about github-download-parts cli
$ repo -h
```

### Example

- Download a file or folder form someone github repository

```bash
$ repo -r "username/repository" -t local_folder -p target_file.js
```

- Download the whole repository

```bash
$ repo -r "username/repository" -t local_folder
```

### Options

- `-r --repo <repo>`: Github repository, the format is `"${username}/${repository}"`

- `-t --target <dir>`: The local directory that files will be created into

- `-p --pathname <path>`: The file or folder path of github repository you want to download

## Download Limiting

Because of Github API Rate Limiting, every IP only be allowed 60 requests per hour, So **every IP just only could download 60 times per hour**.

[Know More About Github Rate Limiting](https://developer.github.com/v3/#rate-limiting)

---
_Source: https://npm.io/package/github-download-parts · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
