gpt4 book ai didi

javascript - 使用 gruntjs 自定义初始化任务重命名模板文件夹

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:27:05 25 4
gpt4 key购买 nike

我正在尝试为 Grunt 中的个人模板创建自定义初始化任务 .

这是在 grunt init:mytemplate

之后生成我的新项目的 js
exports.description = 'Try Grunt';
exports.warnOn = '*';

exports.template = function(grunt, init, done) {
grunt.helper('prompt', {type: 'skin'}, [
grunt.helper('prompt_for', 'name', 'trygrunt'),
grunt.helper('prompt_for', 'title', 'Im Trying GruntJS'),
grunt.helper('prompt_for', 'author_name', 'Myself')
],
function(err, props) {
var files = init.filesToCopy(props);
init.copyAndProcess(files, props);
done();
});
};

一切正常:根据 rename.json 信息从自定义模板的 root 文件夹正确生成或重命名文件和文件夹。

问题是:我怎样才能动态重命名文件夹而不仅仅是文件?

{
"libs/name.js": "libs/{%= name %}.js" //this works fine
"src/name": "src/{%= name %}" //this doesn't work
}

最佳答案

init.filesToCopy 方法在首次构建 files 对象时仅查看 renames.json 以查找特定文件(而非目录)匹配项.最好的办法是以编程方式修改 init.filesToCopyinit.copyAndProcess 之间的 files 对象。

关于javascript - 使用 gruntjs 自定义初始化任务重命名模板文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11852283/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com