Skip to content

eush77/github-get

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm

github-get

Build Status Coverage Status Dependency Status CLI Module

Fetch files or list directories from GitHub repositories.

Relevant GitHub API section.

Example

If given a directory path, returns directory listing:

githubGet('eush77/github-get', function (err, files) {
    if (err) throw err;
    console.log(files);
})

//=> [ '.gitignore',
//     '.travis.yml',
//     'LICENSE',
//     'README.md',
//     'cli.js',
//     'index.js',
//     'package.json',
//     'test' ]

If given a file path, returns file contents:

githubGet('eush77/github-get/package.json', function (err, pkg) {
    if (err) throw err;
    console.log(JSON.parse(pkg).description);
})

//=> 'Fetch files and list directories from GitHub repositories'

All data returned from GitHub API is also available:

githubGet('eush77/github-get/package.json', function (err, pkg, data) {
    if (err) throw err;
    console.log(data.download_url);
})

//=> 'https://raw.githubusercontent.com/eush77/github-get/master/package.json'

API

githubGet(["owner/repository[/path]"], [options], callback(err, content, data))

Options

option description default value
owner Owner of the repository (user/organization)
repository Repository name
path Path to file or directory in the repository / (root)
token GitHub token for authentication. Unauthenticated requests to GitHub API are limited to 60 requests per hour. Generate your token here
endpoint API endpoint https://api.github.com/

owner, repository, and path can either be specified in a path string (first argument) or in the options.

content

File contents (array) or directory listing.

data

Data returned by GitHub API. Object or array of objects, depending on whether path is to a file or a directory.

CLI

Install github-get-cli:

$ npm install -g github-get-cli
$ github-get --help

Related

  • github-get-cli — CLI for this module.
  • npm-get — fetch files and list directories from npm packages.

Install

npm install github-get

License

MIT

About

Fetch files and list directories from GitHub repositories

Resources

License

Stars

Watchers

Forks

Packages

No packages published