Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Takeshi Iwana committed Dec 19, 2020
1 parent 010550e commit 0ca3314
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,46 @@ An API to download and/or extract git repositories.
[![Downloads/week](https://img.shields.io/npm/dw/gitly.svg)](https://www.npmjs.com/package/gitly)
[![License](https://img.shields.io/github/license/iwatakeshi/gitly)](https://github.com/iwatakeshi/gitly/blob/master/LICENSE.md)



This project is the spiritual successor of [gittar](https://github.com/lukeed/gittar) written in TypeScript.

## Usage

Since v1.0+

```typescript
import { fetch, extract } = from 'gitly'
import { download, extract } = from 'gitly'

console.log(await fetch('iwatakeshi/gitly'))
console.log(await download('iwatakeshi/gitly'))
// -> ~/.gitly/github/iwatakeshi/gitly/master.tar.gz

console.log(await fetch('iwatakeshi/gitly#v1.0.0'))
console.log(await download('iwatakeshi/gitly#v1.0.0'))
// -> ~/.gitly/github/iwatakeshi/gitly/v1.0.0.tar.gz

console.log(await fetch('https://github.com/iwatakeshi/gitly'))
console.log(await download('https://github.com/iwatakeshi/gitly'))
// -> ~/.gitly/github/iwatakeshi/gitly/master.tar.gz

console.log(await fetch('gitlab:Rich-Harris/buble#v0.15.2'))
console.log(await download('gitlab:Rich-Harris/buble#v0.15.2'))
// -> ~/.gitly/gitlab/Rich-Harris/buble/v0.15.2.tar.gz

console.log(await fetch('Rich-Harris/buble', { host: 'gitlab' }))
console.log(await download('Rich-Harris/buble', { host: 'gitlab' }))
// -> ~/.gitly/gitlab/Rich-Harris/buble/master.tar.gz

const source = 'path to downloaded zip file (can be obtained by fetch())'
const source = 'path to downloaded zip file (can be obtained by download())'
const destination = '/path/to/foobar'

await extract(source, destination)
// -> /path/to/foobar
```

Since v2.0+

```typescript
import gitly from 'gitly'

console.log(await gitly('iwatakeshi/gitly', '/path/to/extracted/folder/'))
// -> ['~/.gitly/github/iwatakeshi/gitly/master.tar.gz', '/path/to/extracted/folder/']
```

## Options

```typescript
Expand All @@ -52,7 +61,7 @@ interface GitlyOptions {
*/
force?: boolean
/**
* Throw an error when fetching (default: undefined)
* Throw an error when downloading (default: undefined)
*/
throw?: boolean
/**
Expand Down

0 comments on commit 0ca3314

Please sign in to comment.