Download repository from github
npm install @nodesecure/github
Download and (optionaly) extract GitHub repository archive.
- Node.js v20 or higher
This package is available in the Node Package Repository and can be easily installed with npm or yarn.
``bash`
$ npm i @nodesecure/githubor
$ yarn add @nodesecure/github
`js
import * as github from "@nodesecure/github";
const utils = await github.download("NodeSecure.utils");
console.log(utils.location);
const scanner = await github.downloadAndExtract("NodeSecure.scanner");
console.log(scanner.location);
`
Both download and downloadAndExtract functions use the same set of options.
`ts`
interface DownloadOptions {
/**
* The destination (location) to extract the tar.gz
*
* @default process.cwd()
*/
dest?: string;
/**
* The default github branch name (master, main ...)
*
* @default main
*/
branch?: string;
/**
* Authentication token for private repositories
*
* @default process.env.GITHUB_TOKEN
*/
token?: string;
}
`ts`
interface DownloadResult {
/* Archive or repository location on disk /
location: string;
/* Github repository name /
repository: string;
/* Github organization name /
organization: string;
/* Github branch name /
branch: string;
}
`ts``
interface DownloadExtractOptions extends DownloadOptions {
/**
* Remove the tar.gz archive after a succesfull extraction
*
* @default true
*/
removeArchive?: boolean;
}
MIT