stonehenge-git-repo

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

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

Repository

https://github.com/PepperYan/download-git-repo


上一篇:swagger-ui-dist
下一篇:maven

相关推荐

  • 鲍尔注册本地的Git包

    鲍尔注册本地的Git包...

    2 年前
  • 高效阅读Github源代码

    三种办法。如果你主要看前端项目的代码,直接看第三种。 1,用Chrome插件Octotree,左侧会出现树形结构,方便你浏览源代码。 (https://img.javascriptcn.com/6...

    2 年前
  • 链接和执行外部JavaScript文件托管在GitHub上

    AuthorProxy(https://stackoverflow.com/users/1763061/authorproxy)提出了一个问题:Link and execute external Ja...

    2 年前
  • 邮件驱动 Git 工作流的优势

    git 2.18.0(/go/?target=https%3A%2F%2Fraw.githubusercontent.com%2Fgit%2Fgit%2Fmaster%2FDocumentation%...

    2 年前
  • 那些年前端接触的Git知识大全

    1、Git诞生的历史 Git的定义 Git是当下最先进的开源分布式版本控制系统,可以高效便捷地管理大大小小的项目版本 所谓的分布式,按我的理解就是主要专注于分字,分开,分离,把某些事物分开布置在...

    1 个月前
  • 通过 41 个 问答方式快速了解学习 Git

    为了保证的可读性,本文采用意译而非直译。 1. 你最喜欢的 Git 命令是什么 个人比较喜欢 这增加了“补丁模式”的变化,这是一个内置的命令行程序。它遍历了每个更改,并要求确认是否要执行它们。

    9 个月前
  • 谈谈git分支管理的本质

    前言 想了想工作两年中自己做的事情,发现这方面还算不错,所以拎出来说说自己对 git 的一些理解。 粗略浏览了一下网上存在的 Git 相关的中文文章,大多数是介绍 Git 的一些命令怎么使用,或者是介...

    1 个月前
  • 详解 Github App 的玩法

    image(https://img.javascriptcn.com/8ee2bda1b962f5c4f8ece5c07608382e "image") 之前在使用 Github issues 搭建...

    1 年前
  • 让你印象深刻的代码| Gitee「分享代码赢礼品」活动

    写过千千万万行代码,你印象最深的是哪个?快来晒晒代码,赢取 Gitee 大礼吧~ 活动传送门<< 活动时间 2020.5.27 ~ 2020.6.12 参与方式 1、在 Gitee 指定活...

    2 个月前
  • 解决sourceTree的git clone 报SSH密钥认证失败的问题

    好不容易通过了不用登录sourceTree的问题,开开森森打开sourceTree的时候,使用Clone的时候发现还是无法使用会报SSH错认证失败,崩溃! clipboard.png(https:/...

    2 年前

官方社区

扫码加入 JavaScript 社区