A tool to download git repository.
npm install repo-git-downloader --save
# OR
yarn add repo-git-downloader --save
You can customize the name and reference this package. Such as:
const download = require('repo-git-downloader')
download
receives 3 parameters:
- url:
Required
- options:
Optional
- callback:
Required
It identifies the repository link of git. Support the following types:
owner/name
github:owner/name
git@github.com:owner/name.git
https://github.com/owner/name.git
If you want to get a branch(dev, etc.) or tag(v1.0.0, etc.) from git repository:
owner/name#checkout
github:owner/name#checkout
git@github.com:owner/name#checkout.git
https://github.com/owner#checkout/name.git
gitlab:owner/name
git@gitlab.com:owner/name.git
https://gitlab.com/owner/name.git
You also can get a branch(dev, etc.) or tag(v1.0.0, etc.) from git repository same as above.
It identifies the download type of git. It provides 3 options:
- ssh(defalut)
- https
- direct
The direct
option allow to download a *.zip
file of respository.
Notes: If you use ssh, you must generate ssh ECDSA key at git repository
It identifies the location of the download. Default is current directory(./
). You can define absolute paths and relative paths.
- Boolean: true|false(defalut)
It define a custom git url if you use the company's internal network or private repository.
The callback when download complete or throw a error. Having a parameter: (err) => {}
- simple download:
download('mnichangxin/repo-git-downloader', (err) => {
if (err) {
// handle err
return
}
// handle done
})
- Provide option type:
Although it is github https
url, but using type: ssh
to download by ssh
type.
download('https://github.com/mnichangxin/repo-git-downloader.git', {
type: 'ssh'
}, (err) {
if (err) {
// handle err
return
}
// handle done
})
- checkout download:
It will download dev
branch of repository.
download('mnichangxin/repo-git-downloader#dev', (err) => {
if (err) {
// handle err
return
}
// handle done
})