stonehenge-git-repo

2019-12-04

stonehenge-git-repo是什么

什么是stonehenge-git-repo,Download and extract a git repository (GitHub, GitLab, Bitbucket) from node.

stonehenge-git-repo使用教程帮助文档

download-git-repo

Download and extract a git repository (GitHub, GitLab, Bitbucket) from node.

Installation

$ npm install download-git-repo

API

download(repository, destination, options, callback)

Download a git repositoryto a destinationfolder with options, and callback.

repository

The short hand repository string to download the repository from:

  • GitHub - github:owner/nameor simply owner/name
  • GitLab - gitlab:owner/name
  • Bitbucket - bitbucket:owner/name

The repositoryparameter defaults to the masterbranch, but you can specify a branch or tag as a URL fragment like owner/name#my-branch. In addition to specifying the type of where to download, you can also specify a custom origin like gitlab:custom.com:owner/name. Custom origin will default to httpsor git@for http and clone downloads respectively, unless protocol is specified. Feel free to submit an issue or pull request for additional origin options.

destination

The file path to download the repository to.

options

An optional options object parameter with download options. Options include:

  • clone- boolean default false- If true use git cloneinstead of an http download. While this can be a bit slower, it does allow private repositories to be used if the appropriate SSH keys are setup.

callback

The callback function as function (err).

Examples

Using http download from Github repository at master.

download('flipxfx/download-git-repo-fixture', 'test/tmp', function (err) {
  console.log(err ? 'Error' : 'Success')
})

Using git clone from Bitbucket repository at my-branch.

download('bitbucket:flipxfx/download-git-repo-fixture#my-branch', 'test/tmp', { clone: true }, function (err) {
  console.log(err ? 'Error' : 'Success')
})

Using http download from GitLab repository with custom origin.

download('gitlab:mygitlab.com:flipxfx/download-git-repo-fixture#my-branch', 'test/tmp', function (err) {
  console.log(err ? 'Error' : 'Success')
})

Using git clone from GitLab repository with custom origin and protocol. Note that the repository type (github, gitlabetc.) is not required if cloning from a custom origin.

download('https://mygitlab.com:flipxfx/download-git-repo-fixture#my-branch', 'test/tmp', { clone: true }, function (err) {
  console.log(err ? 'Error' : 'Success')
})

Direct

Using http download from direct url.

download('direct:https://gitlab.com/flipxfx/download-git-repo-fixture/repository/archive.zip', 'test/tmp', function (err) {
  console.log(err ? 'Error' : 'Success')
})

Using git clone from direct url at master.

download('direct:https://gitlab.com/flipxfx/download-git-repo-fixture.git', 'test/tmp', { clone: true }, function (err) {
  console.log(err ? 'Error' : 'Success')
})

Using git clone from direct url at my-branch.

download('direct:https://gitlab.com/flipxfx/download-git-repo-fixture.git#my-branch', 'test/tmp', { clone: true }, function (err) {
  console.log(err ? 'Error' : 'Success')
})

Thanks

To ianstormtaylor/download-github-repofor the head start.

License

MIT


上一篇:swagger-ui-dist
下一篇:maven
相关教程
关注微信

扫码加入 JavaScript 社区

相关文章

首次访问,需要验证
微信扫码,关注即可
(仅需验证一次)

欢迎加入 JavaScript 社区

号内回复关键字:

回到顶部