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:<git repository url>', src/uni-app, { clone: true }, function (err) {
  console.log(err ? 'Error:' : 'Success:')    
})

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