grunt-init模板条件提示 [英] grunt-init template conditional prompts

查看:163
本文介绍了grunt-init模板条件提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为自己的项目创建了一个新的 grunt-init 模板,并在想如果是一种根据给以前提示的答案进行条件提示的方法。



我的主要目标是在创建时能够使用Github API创建问题我的项目中有一个新模块。在询问模块信息后,我会问是否应该创建一个Github问题。如果是,那么请索取受让人,里程碑,标签等信息。如果没有,我不在乎任何这些功能。



现在,我可以将它们默认为空白,但我想跳过这些提示 init 属性暴露了 > init.prompts()可以根据答案修改的对象。



类似于这样:

  exports.template = function(grunt ,init,done){
init.process([
init.prompt('create_github_issue',function(value,props,done){
init.prompts ['milestone'] = init .prompt('milestone');
done();
})
],function(err,props){
//处理所有道具
done ();
});
};

请参阅 gruntplugin模板,了解如何实施初始化任务。


I'm creating a new grunt-init template for my project and was wondering if there is a way to do conditional prompts based on the answers given to previous prompts.

My main goal is to be able to use the Github API to create an issue when I create a new module in my project. After asking for the module information, I would ask if a Github issue should be created. If yes, then ask for information like assignee, milestone, labels. If no, I don't care about any of those features.

Right now, I can just default them to blanks, but I'd like to just skip those prompts entirely.

解决方案

The init property exposes a init.prompts() object which you could modify based on the answers.

Something like this:

exports.template = function(grunt, init, done) {
    init.process([
        init.prompt('create_github_issue', function(value, props, done) {
            init.prompts['milestone'] = init.prompt('milestone');
            done();
        })
    ], function(err, props) {
        // handle all the props
        done();
    });
};

See the gruntplugin template for how to implement an init task.

这篇关于grunt-init模板条件提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆