Browse Source

功能修复

master
1549469775 3 years ago
parent
commit
e0ac8b8748
  1. 11
      dist/pp.cjs.js
  2. 2
      dist/pp.cjs.js.map
  3. 2
      package.json
  4. 4
      src/func.ts
  5. 2
      src/index.ts
  6. 4
      src/writefile.ts

11
dist/pp.cjs.js

@ -239,9 +239,10 @@ function isExist(file) {
return result;
}
var exclude = ['.png', '.jpg', '.jpeg', '.zip', '.rar', '.webp'];
function writefile(fromDir, toDir, opts, force) {
function writefile(fromDir, toDir, opts, force, isEjs) {
if (opts === void 0) { opts = {}; }
if (force === void 0) { force = false; }
if (isEjs === void 0) { isEjs = true; }
if (!fromDir) {
console.log(chalk__default["default"].red("缺少模板目录"));
return;
@ -265,7 +266,7 @@ function writefile(fromDir, toDir, opts, force) {
});
try {
var ext = path__default["default"].parse(fromRes).ext;
if (exclude.includes(ext)) {
if (exclude.includes(ext) || !isEjs) {
fs__default["default"].copyFileSync(fromRes, toRes);
}
else {
@ -574,7 +575,7 @@ function onCopy(templateDir, opts) {
}
writefile(templateDir, opts.targetDir, vars);
}
function onClone(name, target) {
function onClone(name, target, cc) {
var item = Data.getInstance().findOne(name);
if (!item) {
console.log("\u8BF7\u5148\u6DFB\u52A0\u8BE5\u9879\u76EE");
@ -605,7 +606,7 @@ function onClone(name, target) {
if (err)
throw err;
console.log("临时文件夹为:" + tempPath);
writefile(tempPath, to, { name: "哈哈" });
writefile(tempPath, to, opts, false, !cc.ignore);
fs__default["default"].removeSync(tempPath);
console.log(chalk__default["default"].green("已清除临时文件夹"));
console.log(chalk__default["default"].green("克隆成功"));
@ -674,7 +675,7 @@ program
.command("remove <name>")
.description("删除一个模板仓库")
.action(onRemove);
program.command("clone <name> <target>").description("克隆模板仓库").action(onClone);
program.command("clone <name> <target>").option("-i --ignore", "是否不需要模板变量").description("克隆模板仓库").action(onClone);
program.command("copy <templateDir>")
.requiredOption("-d --targetDir <targetDir>", "目标路径")
.option("-p --p <p>", "模板变量")

2
dist/pp.cjs.js.map

@ -1 +1 @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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}

2
package.json

@ -1,6 +1,6 @@
{
"name": "@noderun/pp",
"version": "0.0.4",
"version": "0.0.6",
"description": "命令行管理模板项目",
"main": "dist/pp.umd.js",
"module": "dist/pp.esm.js",

4
src/func.ts

@ -102,7 +102,7 @@ export function onCopy(templateDir: string, opts: { targetDir: string, p:string
writefile(templateDir, opts.targetDir, vars);
}
export function onClone(name: string, target: string) {
export function onClone(name: string, target: string, cc: { ignore?:boolean }) {
const item = Data.getInstance().findOne(name)
if (!item) {
console.log(`请先添加该项目`);
@ -136,7 +136,7 @@ export function onClone(name: string, target: string) {
download(git_url, tempPath, { clone: true }, function (err: Error) {
if (err) throw err;
console.log("临时文件夹为:" + tempPath);
writefile(tempPath, to, { name: "哈哈" });
writefile(tempPath, to, opts, false, !cc.ignore);
fs.removeSync(tempPath);
console.log(chalk.green("已清除临时文件夹"));
console.log(chalk.green("克隆成功"));

2
src/index.ts

@ -40,7 +40,7 @@ program
.description("删除一个模板仓库")
.action(func.onRemove);
program.command("clone <name> <target>").description("克隆模板仓库").action(func.onClone);
program.command("clone <name> <target>").option("-i --ignore", "是否不需要模板变量").description("克隆模板仓库").action(func.onClone);
program.command("copy <templateDir>")
.requiredOption("-d --targetDir <targetDir>", "目标路径")
.option("-p --p <p>", "模板变量")

4
src/writefile.ts

@ -33,7 +33,7 @@ export function isExist (file: string) {
const exclude = ['.png','.jpg','.jpeg','.zip','.rar','.webp']
export default function writefile (fromDir: string, toDir: string, opts = {}, force = false) {
export default function writefile (fromDir: string, toDir: string, opts = {}, force = false, isEjs = true) {
if (!fromDir) {
console.log(chalk.red("缺少模板目录"))
return
@ -57,7 +57,7 @@ export default function writefile (fromDir: string, toDir: string, opts = {}, fo
});
try{
let ext = path.parse(fromRes).ext
if(exclude.includes(ext)){
if(exclude.includes(ext) || !isEjs){
fs.copyFileSync(fromRes, toRes)
}else {
const html = ejs.render(originRoot, opts);

Loading…
Cancel
Save