download-git-repo 用法

download-git-repo 是个npm包,用来从一个代码仓库中下载代码用的。官网摘抄如下:

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

接口如下:

download(repository, destination, options, callback)

Download a git repository to a destination folder with options, and callback.

此API的第一个参数repository 用两种写法,一个是代码仓库的简写形式:

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

例如你的GitHub上有个项目,可以这么写:

const download = require('download-git-repo');
download('github:liubbc/uni-app',src/uni-app, function (err) {
   console.log(err ? 'Error:' : 'Success:')    
})

这样写是不行的:

const download = require('download-git-repo');
download('git@github.com:liubbc/uni-app.git', src/uni-app, function (err) {
   console.log(err ? 'Error:' : 'Success:')    
})

另外一种写法是直接写url的形式,例如:

const download = require('download-git-repo');
download('direct:https://github.com/liubbc/uni-app.git', src/uni-app, { clone: true }, function (err) {
          console.log(err ? 'Error:' : 'Success:')    
})

如果我们的项目代码放在了gerrit库中,那么要用直接写url的形式,例如:

const download = require('download-git-repo');
download('direct:http://10.128.128.128:8092/HTML5/miniProgram', src/uni-app, { clone: true }, function (err) {
          console.log(err ? 'Error:' : 'Success:')    
      })

详细用法还是看download-git-repo 官网

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值