潜在的n00b问题,但谷歌没有一个好的简洁的答案-让我们一起解决。
我是从咕哝开始的,我被困在一些基本的东西上。我发现--init已经被移动到了一个单独的过程--文档周围的碎片一开始并不是很明显,但这很酷。
我现在决定要我自己的grunt-init模板,它位于我的站点的根目录中(目前,直到是时候将它移到~/.grunt-init dir中为止)。我用的是咕噜声0.3.17
在浏览grunt init -jquery和其他init模板时,我注意到它们都使用标准init提示。
我想创建一些自定义提示与客户相关的信息,也许添加客户端电子邮件,或项目经理的名字。
但在我的一生中,我无法弄清楚如何创建/存储一个可以在咕噜-init中调用的自定义提示符。
感谢你的任何帮助
发布于 2013-02-07 21:44:46
更新: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
});其中,提示参数是一个对象数组。您可以在不注册新助手或扩展提示符的情况下添加自己的。
可以添加如下自定义提示:
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
});https://stackoverflow.com/questions/14742591
复制相似问题