diff --git a/dist/pp.cjs.js b/dist/pp.cjs.js index 37c0f71..abd432b 100644 --- a/dist/pp.cjs.js +++ b/dist/pp.cjs.js @@ -602,7 +602,8 @@ function onClone(name, target, cc) { console.log(chalk__default["default"].red("您存储的变量解析出错了,请先检查")); } } - download__default["default"](git_url, tempPath, { clone: true }, function (err) { + var branch = item.branch; + download__default["default"](branch ? git_url + '#' + branch : git_url, tempPath, { clone: true }, function (err) { if (err) throw err; console.log("临时文件夹为:" + tempPath); @@ -665,6 +666,7 @@ program .option("-d --desc ", "模板具体描述") .option("-t --tag ", "模板标签") .option("-v --var ", "模板变量") + .option("-b --branch ", "仓库分支") .description("添加一个模板仓库") .action(onAdd); program @@ -673,6 +675,7 @@ program .option("-t --tag ", "模板标签") .option("-u --url ", "仓库地址") .option("-p --p

", "模板变量") + .option("-b --branch ", "仓库分支") .description("修改模板仓库") .action(onModify); program diff --git a/dist/pp.cjs.js.map b/dist/pp.cjs.js.map index 2d17c16..29781e9 100644 --- a/dist/pp.cjs.js.map +++ b/dist/pp.cjs.js.map @@ -1 +1 @@ -{"version":3,"file":"pp.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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--git a/package.json b/package.json index f0e320f..79f3db2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@noderun/pp", - "version": "0.0.8", + "version": "0.0.10", "description": "命令行管理模板项目", "main": "dist/pp.umd.js", "module": "dist/pp.esm.js", diff --git a/src/func.ts b/src/func.ts index 2851d31..3ba660f 100644 --- a/src/func.ts +++ b/src/func.ts @@ -133,7 +133,8 @@ export function onClone(name: string, target: string, cc: { ignore?:boolean }) { ); } } - download(git_url, tempPath, { clone: true }, function (err: Error) { + const branch = item.branch; + download(branch?git_url+'#'+branch:git_url, tempPath, { clone: true }, function (err: Error) { if (err) throw err; console.log("临时文件夹为:" + tempPath); writefile(tempPath, to, opts, false, !cc.ignore); @@ -153,7 +154,7 @@ export function onRemove(name: string) { } } -export function onModify(name: string, opt: { desc?: string, url?:string,tag?:string,p?:string }) { +export function onModify(name: string, opt: { desc?: string, url?:string,tag?:string,p?:string,branch?: string }) { const http = /^(http|https)\:\/\//g; const git = /(git|root)\@/g; if (opt.url&&!git.test(opt.url) && !http.test(opt.url)) { @@ -164,7 +165,7 @@ export function onModify(name: string, opt: { desc?: string, url?:string,tag?:st console.log(chalk.green("修改成功")); } -export function onAdd(url: string, name: string, opt: { desc?: string,tag?:string,var?:string }) { +export function onAdd(url: string, name: string, opt: { desc?: string,tag?:string,var?:string,branch?: string }) { const http = /^(http|https)\:\/\//g; const git = /(git|root)\@/g; if (!git.test(url) && !http.test(url)) { diff --git a/src/index.ts b/src/index.ts index 704ce74..1fcd733 100644 --- a/src/index.ts +++ b/src/index.ts @@ -25,6 +25,7 @@ program .option("-d --desc ", "模板具体描述") .option("-t --tag ", "模板标签") .option("-v --var ", "模板变量") + .option("-b --branch ", "仓库分支") .description("添加一个模板仓库") .action(func.onAdd); program @@ -33,6 +34,7 @@ program .option("-t --tag ", "模板标签") .option("-u --url ", "仓库地址") .option("-p --p

", "模板变量") + .option("-b --branch ", "仓库分支") .description("修改模板仓库") .action(func.onModify); program