【问题标题】:grunt-init template conditional promptsgrunt-init 模板条件提示
【发布时间】:2013-01-04 02:25:29
【问题描述】:

我正在为我的项目创建一个新的grunt-init 模板,并且想知道是否有办法根据对先前提示的答案进行条件提示。

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

现在,我可以将它们默认为空白,但我想完全跳过这些提示。

【问题讨论】:

    标签: node.js prompt gruntjs


    【解决方案1】:

    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) {
            // handle all the props
            done();
        });
    };
    

    请参阅gruntplugin template 了解如何实现初始化任务。

    【讨论】:

    • 我认为这看起来很有希望,但由于某种原因,它从不询问我函数内的提示。它似乎只是问了第一个问题,然后飞过这个函数,而不用做任何事情。此外,该示例没有任何内部提示。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多