mbe*_*ley 8 javascript node.js gruntjs
我正在尝试使用Grunt在项目中创建一个目录,以便在博客上发布新帖子.它本质上会在一个posts名为的目录中创建一个目录YYYYMMDDDD-PostNameInPascalCase.
为了做到这一点,我每次执行任务时都必须提示用户输入帖子名称.我知道grunt-init会提示用户从项目模板创建项目,但我很好奇是否有办法在Gruntfile.js已经建立的项目的文件中执行此操作.
有什么想法吗?
Gle*_*lle 13
自上次提出这个问题以来已经有一段时间了,但Github上有一个项目试图做提问者正在寻找的问题.它被称为grunt-prompt,这里是网址:https://github.com/dylang/grunt-prompt.它基本上是一种将提示集成到Gruntfile中的方法.从项目自述文件中你可以做类似的事情:
grunt.initConfig({
prompt: {
target: {
options: {
questions: [
{
config: 'config.name', // arbitray name or config for any other grunt task
type: '<question type>', // list, checkbox, confirm, input, password
message: 'Question to ask the user',
default: 'value', // default value if nothing is entered
choices: 'Array|function(answers)',
validate: function(value), // return true if valid, error message if invalid
filter: function(value), // modify the answer
when: function(answers) // only ask this question when this function returns true
}
]
}
},
},
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6542 次 |
| 最近记录: |