# github-download

> Easily download Github repos without any external dependencies such as Git, Tar, Unzip, etc.

Latest version **0.5.0** (published 2016-05-04) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2016-05-04 |
| First published | 2013-01-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+3 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 77 |
| Author | JP Richardson |
| Maintainers | jprichardson |
| Keywords | github, repository, repo, download, fetch, git |

## Links

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

## Dependencies (4)

- [vcsurl](https://npm.io/package/vcsurl.md) ~0.1.0
- [adm-zip](https://npm.io/package/adm-zip.md) ~0.4.3
- [request](https://npm.io/package/request.md) ^2.12.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^0.24.0

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 0.5.0 (latest) — 2016-05-04
- 0.4.0 — 2015-08-30
- 0.3.0 — 2014-06-17
- 0.2.0 — 2013-04-29
- 0.1.1 — 2013-02-03
- 0.1.0 — 2013-01-21
- 0.0.1 — 2013-01-17

## README

Node.js - github-download
================

[![build status](https://secure.travis-ci.org/jprichardson/node-github-download.svg)](http://travis-ci.org/jprichardson/node-github-download)

Easily download Github repos without any external dependencies such as Git, Tar, Unzip, etc.


Why?
----

I really like the concept of managing user defined projects, repos, file structures (package management) on Github like the way that [Component](https://github.com/component) does package management. I have a package management system [Rock](https://github.com/rocktemplates) that I use to create skeleton/templates of projects. I wanted Rock to use Github as a package management system. I also didn't want any dependencies amongst any 3rd party programs like Git, Tar, or Unzip. Pure Node.js JavaScript is what I wanted.


Installation
------------

    npm install github-download



Usage
-----

### ghdownload(params, dir)

Downloads the latest copy of some Github reference (branch, tag, or commit), or the `master` branch by default (specifically the `master` branch, it does _not_ honor Github's default branch configuration). This will still work even if the Github API limit has been reached.

- **params**: Can either be:
     - a Github URL string such as:
         - `https://github.com/jprichardson/node-vcsurl.git`
         - `git@github.com:jprichardson/node-vcsurl.git`
         - `git://github.com/jprichardson/node-vcsurl.git`
         - and even including a reference, e.g. `https://github.com/jprichardson/node-vcsurl.git#master`
     - or an object like so: `{user: 'jprichardson', repo: 'vcsurl', ref: 'master'}`
- **dir**: The output directory. Uses the current working directory if nothing is specified.

Returns a GithubDownloader object that emits events on `dir`, `file`, and `end`.

Example:

```javascript
var ghdownload = require('github-download')
  , exec = require('exec')

ghdownload({user: 'jprichardson', repo: 'node-batchflow', ref: 'master'}, process.cwd())
.on('dir', function(dir) {
  console.log(dir)
})
.on('file', function(file) {
  console.log(file)
})
.on('zip', function(zipUrl) { //only emitted if Github API limit is reached and the zip file is downloaded
  console.log(zipUrl)
})
.on('error', function(err) {
  console.error(err)
})
.on('end', function() {
  exec('tree', function(err, stdout, sderr) {
    console.log(stdout)
  })
})
```

Outputs:

    .
    ├── CHANGELOG.md
    ├── LICENSE
    ├── README.md
    ├── lib
    │   └── batchflow.js
    ├── package.json
    └── test
        ├── batchflow-par-array.test.js
        ├── batchflow-par-limit.test.js
        ├── batchflow-par-object.test.js
        ├── batchflow-seq-array.test.js
        ├── batchflow-seq-object.test.js
        ├── batchflow.test.js
        ├── mocha.opts
        └── resources

    3 directories, 12 files



License
-------

(MIT License)

Copyright 2013-2016, JP Richardson  <jprichardson@gmail.com>

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