github-extractor / GithubExtractor / GithubExtractor
GithubExtractor
The main class
Constructors
new GithubExtractor(options)
new GithubExtractor(options): GithubExtractor
Parameters
• options: GithubExtractorOptions
Main class constructor options.
Returns
Properties
branch
branch: undefined | string;
caseInsensitive
caseInsensitive: undefined | boolean;
owner
owner: string;
repo
repo: string;
Methods
downloadTo()
downloadTo(options): Promise<Typo[]>
Download a repo to a certain location (dest
)
Parameters
• options: DownloadToOptions
Returns
Promise
<Typo
[]>
- An empty array if all
selectedPaths
were found / there were noselectedPaths
given OR an array of possible typos if some of theselectedPaths
were not found.
Example
Basic usage:
await ghe.downloadTo({ dest: "some/path" });
To only download some paths:
Do not prefix path 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"] });
getLocalDirSet()
getLocalDirSet(dir, recursive): Promise<Set<string>>
Get a set of the contents of a directory, sorted using using string.localeCompare (with directories listed first). all paths are converted to posix and are relative to the given dir.
Parameters
• dir: string
• recursive: boolean
= true
default true
Returns
Promise
<Set
<string
>>
list()
list(options): Promise<ListItem[]>
Returns a list of files in the repo and writes to (by default) stdout (console.log). Supply an object with options to change defaults.
Parameters
• options: ListOptions
= {}
Returns
Promise
<ListItem
[]>
Example
const fullList = await ghe.list();
// List a repo non recursively to only show the top-level items:
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 });