github-get

Fetch files and list directories from GitHub repositories

Usage no npm install needed!

<script type="module">
  import githubGet from 'https://cdn.skypack.dev/github-get';
</script>

README

npm

github-get

Build Status Dependency Status

Fetches files and lists directories from GitHub repositories. Decodes base64.

Relevant GitHub API section.

Example

$ github-get eush77 github-get
test/
.gitignore
.travis.yml
LICENSE
README.md
cli.js
index.js
package.json
$ github-get eush77 github-get test/test.js
'use strict';

var test = require('tape'),
    rewire = require('rewire');
# ...

CLI

github-get [-l | --long] [--pager] <user> <repo> [<path>]

Lists directory or cats file contents at <path>.

With --long, prints full paths instead of relative names.

With --pager, shows result in a $PAGER. This is not equivalent to github-get ... | $PAGER. Instead, the pager gets the file name argument which allows for syntax highlighting (e.g. via $LESSOPEN hook).

API

githubGet(owner, repo, [path], [options], callback(err, data, content))

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

path

Path to file in repository. Defaults to / (root).

data

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

content

File contents (array) or directory listing.

options.decode

Boolean. If enabled, file contents will be decoded. No-op for directories. Defaults to true.

options.token

GitHub token for authentication. Unauthenticated requests to GitHub API are limited to only 60 requests per hour. Generate your token here.

options.endpoint

API endpoint to talk to. Defaults to https://api.github.com/.

Related

  • npm-get — fetch files and list directories from npm packages.

Install

npm install -g github-get

License

MIT