JSPM

  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q37584F
  • License ISC

Github Extractor: List or download a whole repo or specific files and folders very quickly

Package Exports

  • github-extractor
  • github-extractor/dist/source/index.mjs

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 (github-extractor) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

header logo: Github Extractor

List github repositories and download individual files or whole repos. ~200% faster than clone depth=1 for an entire repo and much, much faster if you just need a single file.

Continuous Integration status badge Code coverage badge GitHub issues badge Pull requests welcome badge

Install

npm install github-extractor

Usage

Initialize

import githubExtractor from "github-extractor";

const ghe = new githubExtractor({
    owner: "octocat",
    repo: "Spoon-Knife",
    // The default: Readme.md is a different file to README.md
    caseInsensitive: false, 
})

List

const fullList = await ghe.list();

// List a repo non recursively to only show the top-level items (recursive is true by default):
const topLevel = await ghe.list({ recursive: false }); 

// Show any conflicts that might arise if downloading to `dest`:
const conflicts = await ghe.list({ dest: "some/path", conflictsOnly: true });
   

Download

await ghe.downloadTo({ dest: "some/path" });

Using selectedPaths: Downloads only the paths in the repo specified. Do not prefix with repo name. It will stop downloading once it has the file. This can make getting a single file from a large repo very fast.

// Save just `boo.jpg`:
await ghe.downloadTo({ dest: "some/path", selectedPaths: ["someFolder/boo.jpg"] });

// just the `README.md` file: 
await ghe.downloadTo({ dest: "some/path", selectedPaths: ["README.md"] });
   

There are more options and they're all documented using jsdoc so will appear in intellisense.