Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tommypop2/begit
Clone git repositories with ease from Javascript
https://github.com/tommypop2/begit
Last synced: 24 days ago
JSON representation
Clone git repositories with ease from Javascript
- Host: GitHub
- URL: https://github.com/tommypop2/begit
- Owner: Tommypop2
- License: mit
- Created: 2023-09-10T09:50:24.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-22T09:05:12.000Z (about 2 months ago)
- Last Synced: 2024-09-24T04:22:54.469Z (about 2 months ago)
- Language: TypeScript
- Homepage:
- Size: 493 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Begit
A smaller and lighter degit alternative with typescript support.
## Features
- Fast
- Caches results by default so nothing is refetched unnecessarily
- Small
- Only 13.1kB unpacked on [npm](https://www.npmjs.com/package/@begit/core?activeTab=readme) (actual source code is more like 1.4kB minified)
- Fault-tolerant
- Can recover from a corrupted cache file
- XDG Friendly
- Respects [XDG directories](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)
- Minimal Dependencies
- Only has a single dependency ([tar](https://www.npmjs.com/package/tar)) for extracting the downloaded tarballs## Begit CLI
A small CLI wrapper for `@begit/core`
## Installation
Run `npm i -g @begit/cli` to install. Invoke with `begit`
## Usage
For a comprehensive list of features, use the help command as below:
```bash
begit --help
```Which will print something like:
```bash
begitARGUMENTS:
- The URL to clone
[Destination] - a string [optional]OPTIONS:
--subdir, -s - a string [optional]FLAGS:
--help, -h - show help
```### Cloning a repositoy
To clone a repository to the current working directory, simply:
```bash
begit Tommypop2/begit
```URLs are also accepted:
```bash
begit https://github.com/Tommypop2/begit
```You can also specify the desired branch via a `#`:
```bash
begit Tommypop2/begit#main
```### Cloning a subdirectory within a repo
Use any of the above options in conjunction with the `--subdir` flag.
```bash
begit Tommypop2/begit --subdir packages
```Or, shortened to `-s`
```bash
begit Tommypop2/begit -s packages
```## API Reference
## Cloning to a directory
```ts
import { downloadRepo } from "@begit/core";
await downloadRepo({
repo: {
owner: "Tommypop2",
name: "begit",
branch: undefined,
subdir: undefined,
},
"cool_project",
});
```The code above downloads this repository into a folder named `cool_project`.
Alternatively, `downloadAndExtract` could be used in place of `downloadRepo` to opt out of automatically attempting to handle errors