Comparing version 1.0.19 to 1.0.54
@@ -150,2 +150,6 @@ import glob from 'fast-glob'; | ||
* 拷贝模版文件 | ||
* | ||
* 基于 lodash.template 方法来解析模版,并增加了对 | ||
* 1. <%_ _%> 的支持,可用于移除前后的空格或 Tab 符号 | ||
* 2. 增加了对 -%> 的支持,可用于移除控制语句引入的换行符 | ||
* @param opts - 拷贝选项 | ||
@@ -152,0 +156,0 @@ */ |
@@ -231,8 +231,11 @@ "use strict"; | ||
async prompting() { | ||
this.answers = await (0, prompts_1.default)(this.questions, { | ||
onCancel() { | ||
// 用户取消时自动退出 | ||
process.exit(0); | ||
} | ||
}); | ||
var _a; | ||
if ((_a = this.questions) === null || _a === void 0 ? void 0 : _a.length) { | ||
this.answers = await (0, prompts_1.default)(this.questions, { | ||
onCancel() { | ||
// 用户取消时自动退出 | ||
process.exit(0); | ||
} | ||
}); | ||
} | ||
} | ||
@@ -272,6 +275,14 @@ /** | ||
* 拷贝模版文件 | ||
* | ||
* 基于 lodash.template 方法来解析模版,并增加了对 | ||
* 1. <%_ _%> 的支持,可用于移除前后的空格或 Tab 符号 | ||
* 2. 增加了对 -%> 的支持,可用于移除控制语句引入的换行符 | ||
* @param opts - 拷贝选项 | ||
*/ | ||
async copyTemplate(opts) { | ||
const tpl = await fs_extra_1.default.readFile(opts.path, 'utf-8'); | ||
let tpl = await fs_extra_1.default.readFile(opts.path, 'utf-8'); | ||
// 移除控制语句前 <%_ _%> 后的空格或 Tab 符号 | ||
tpl = tpl.replace(/[ \t]*<%_/gm, '<%').replace(/_%>[ \t]*/gm, '%>'); | ||
// 移除控制语句结尾引入的换行符 | ||
tpl = tpl.replace(/-%>(?:\r\n|\r|\n)?/gm, '%>'); | ||
const content = (0, lodash_1.template)(tpl)(opts.context); | ||
@@ -278,0 +289,0 @@ await fs_extra_1.default.mkdirp((0, path_1.dirname)(opts.to)); |
{ | ||
"name": "takin", | ||
"version": "1.0.19", | ||
"version": "1.0.54", | ||
"description": "Front end engineering base toolchain and scaffold", | ||
@@ -70,3 +70,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "8c63c604fe1562b099e193929444ad30316e4da6" | ||
"gitHead": "9b7f54480b0bc4cb2d63cac036abac6c9fed2394" | ||
} |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
393452
7255
3