GDL - GitHub Download
Download any folder from GitHub Repo url.
Usage
npx gdl https://github.com/KusStar/gdl ./gdl
- Or use it in your project, see Install
Install
npm i gdl
Commonjs
const { download, downloadWithCheck } = require('gdl')
downloadWithCheck('https://github.com/KusStar/gkd', './gdl')
ES6
import { download, downloadWithCheck } from 'gdl'
downloadWithCheck('https://github.com/KusStar/gdl', './gdl')
Interfaces
import { Options } from 'got';
declare type RepoInfo = {
username: string;
name: string;
branch: string;
filePath: string;
};
declare function isUrlOk(url: string): Promise<boolean>;
declare function getRepoInfo(url: URL, gotOptions?: Options): Promise<RepoInfo | undefined>;
declare function hasRepo({ username, name, branch, filePath }: RepoInfo): Promise<boolean>;
declare function downloadAndExtractRepo(root: string, { username, name, branch, filePath }: RepoInfo, caching?: boolean): Promise<unknown>;
interface Links {
self: string;
git: string;
html: string;
}
interface ContentItem {
name: string;
path: string;
sha: string;
size: number;
url: string;
html_url: string;
git_url: string;
download_url?: any;
type: string;
_links: Links;
}
declare function getRepoContents(url: string): Promise<ContentItem[]>;
declare function download(url: string, targetDir?: string): Promise<unknown>;
declare type Callback = (dir: string) => void | Promise<void>;
declare function downloadWithCheck(url: string, targetDir?: string, ifExistsCallback?: Callback, notExistsCallback?: Callback): Promise<void>;
export { Callback, ContentItem, Links, RepoInfo, download, downloadAndExtractRepo, downloadWithCheck, getRepoContents, getRepoInfo, hasRepo, isUrlOk };
Thanks
License