From 0ca33149dd6b178526ff9a1449c2a1567b043c25 Mon Sep 17 00:00:00 2001 From: Takeshi Iwana Date: Sat, 19 Dec 2020 13:44:38 -0700 Subject: [PATCH] Update readme --- README.md | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 400bff0..d4278f6 100644 --- a/README.md +++ b/README.md @@ -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 @@ -52,7 +61,7 @@ interface GitlyOptions { */ force?: boolean /** - * Throw an error when fetching (default: undefined) + * Throw an error when downloading (default: undefined) */ throw?: boolean /**