An open API service indexing awesome lists of open source software.

https://github.com/alexxnb/fetch-repo-dir

Download any directory from repository
https://github.com/alexxnb/fetch-repo-dir

Last synced: 3 months ago
JSON representation

Download any directory from repository

Awesome Lists containing this project

README

        

# fetch-repo-dir
Download any directory from repository on GitHub, GitLab or Bitbucket to the specified location. Minimal dependencies, works without *git* or *unzip* in the OS.

## Usage

`fetchRepoDir({src:,dir:},{})`
`fetchRepoDir([{src:,dir:},...],{})`

```javascript

const fetchRepoDir = require('fetch-repo-dir');

...
// this is async function.
try{
//this will copy content of the /templates/default of the repository to the ./template directory
await fetchRepoDir({src:'author/repository/templates/default',dir:'./template'});
}catch(err){
trow new Error(err);
}
...
```

## Options

|Option |Default|Description |
|---------------|-------|------------------------------------------------|
|replace | false | Replace or not existing directory |
|onDownloadStart| (archive_url,tmp_archive)=>{}| Run before download archive of repository |
|onDownloadEnd | (archive_url,tmp_archive)=>{}| Run after download archive of repository |
|onUnpackStart | (tmp_archive,tmp_dir)=>{}| Run before unpacking archive in tmp folder |
|onUnpackEnd | (tmp_archive,tmp_dir)=>{}| Run after unpacking archive in tmp folder |
|onCopyStart | (tmp_path,dest_path)=>{}| Run before copy folder from tmp to destination |
|onCopyEnd | (tmp_path,dest_path)=>{}| Run after copy folder from tmp to destination |