潜在的n00b问题,但谷歌没有一个很好的简洁答案 - 让我们一起修复.
我开始咕噜咕噜,我坚持一些基本的东西.我发现grunt-init已被转移到一个单独的过程中 - 文档周围的碎片一开始并没有让这个显而易见,但那很酷.
我现在决定我想要自己的grunt-init模板,它位于我网站的根目录中(现在,直到它成为时间将它移动到〜/ .grunt-init目录中).我正在使用咕噜声0.3.17
并通过grunt-init-jquery和其他初始化模板 - 我注意到它们都使用标准的init提示.
我想创建一些自定义提示,其中包含与客户端相关的信息,可能会添加客户端电子邮件或项目经理名称.
但我不能为我的生活弄清楚如何创建/在哪里存储可以在grunt-init中调用的自定义提示.
任何帮助赞赏
更新:2012年2月8日
似乎答案似乎在于init.process命令.
启动该过程以开始提示输入. init.process(选项,提示,完成)
init.process({}, [
// Prompt for these values
init.prompt('name'),
init.prompt('description'),
init.prompt('version')
], function(err, props) {
// All finished, do something with the properties
});
Run Code Online (Sandbox Code Playgroud)
其中prompts参数是一个对象数组.您可以在不注册新助手或扩展提示的情况下添加自己的助手.
可以添加自定义提示,如下所示:
init.process({}, [
// Prompt for these values.
{
name: 'client_name',
message: 'Who is the client contact?',
default: 'Joe Smith',
validator: /^[\w\-\.]+$/,
warning: 'Must be only letters, numbers, dashes, dots or underscores. (If this is not for a client, say HOUSE)'
},
{
name: 'project_manager',
message: 'Who is the project manager?',
default: 'Me',
validator: /^[\w\-\.]+$/,
warning: 'Must be only letters, numbers, dashes, dots or underscores.'
}
], function(err, props) {
// All finished, do something with the properties
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1178 次 |
| 最近记录: |