Coder Social home page Coder Social logo

abhicodekr / node-github-download Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jprichardson/node-github-download

0.0 0.0 0.0 31 KB

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

License: MIT License

JavaScript 100.00%

node-github-download's Introduction

Node.js - github-download

build status

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 does package management. I have a package management system Rock 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
      • [email protected]: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:

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 [email protected]

node-github-download's People

Contributors

jprichardson avatar unimonkiez avatar jamesmgreene avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.