Package Exports
- list-github-dir-content
- list-github-dir-content/browser-fetch
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (list-github-dir-content) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
list-github-dir-content 
List all the files in a GitHub repo’s directory
Install
$ npm install list-github-dir-contentUsage
const listContent = require('list-github-dir-content');
const myToken = '000'; // https://github.com/settings/tokens
// They have the same output
const filesArray = await listContent.viaTreesApi('Microsoft/vscode', 'src', myToken);
// OR
const filesArray = await listContent.viaContentsApi('Microsoft/vscode', 'src', myToken);
// OR
const filesArray = await listContent.viaContentsApi('Microsoft/vscode#master', 'src', myToken);
// ['src/file.js', 'src/styles/main.css', ...]
// listContent.viaTreesApi also adds a `truncated` property
if (filesArray.truncated) {
// Perhaps try with viaContentsApi?
}API
listContent.viaTreesApi(identifier, directory, token)
listContent.viaContentsApi(identifier, directory, token)
Both methods return a Promise that resolves with an array of all the files in the chosen directory. They just vary in GitHub API method used. The paths will be relative to root (i.e. if directory is dist/images, the array will be ['dist/images/1.png', 'dist/images/2.png'])
viaTreesApi is preferred when there are a lot of nested directories. This will try to make a single HTTPS request for the whole repo, regardless of what directory was picked. On big repos this may be of a few megabytes. (GitHub API v3 reference)
viaContentsApi is preferred when you're downloading a small part of a huge repo. This will make a request for each subfolder requested, which may mean dozens or hundreds of HTTPS requests. (GitHub API v3 reference)
Notice: while they work differently, they have the same output if no limit was reached.
Known issues:
viaContentsApiis limited to 1000 files per directoryviaTreesApiis limited to around 60,000 files per repo
identifier
Type: string
user/repo or user/repo#reference combination, such as Microsoft/vscode or Microsoft/vscode#master. If the reference is omitted, the default branch will be used.
directory
Type: string
The directory to download, like docs or dist/images
token
Type: string
A GitHub personal token, get one here: https://github.com/settings/tokens
License
MIT © Federico Brigante