Skip to content

vtrbo/load-repo

Repository files navigation

load-repo npm

You need to make sure git is in your path, otherwise you can move on
This is a library based on git-clone development

Install

load-repo

npm install load-repo

Api

loadRepo(repo: string): void


loadRepo(repo: string, path?: string): void


loadRepo(repo: string, path?: string, options?: IOptions): void


loadRepo(repo: string, path?: string, callback?: (error?: Error) => void): void


loadRepo(repo: string, path?: string, options?: IOptions, callback?: (error?: Error) => void): void


repo
// rule: origin:owner/name#branch

const repo = 'github:vtrbo/load-repo#main'

path
// default value process.cwd()

const path = '/'

options
/**
 * IOptions
 * {
 *   if clone is true, keep .git; otherwise, delete it
 *   clone: boolean
 *
 *   if branch is undefined, Clone the default branch
 *   branch: string
 * }
 */

const options = {
  clone: true,
  branch: 'main'
}

callback
// if error exists, it means that the download failed; otherwise, it succeeded

const callback = (error: Error) => {
  if (error)
    console.log('download fail')
  else
    console.log('download success')
}

开源许可证

MIT License © 2022-PRESENT Victor Bo