与eoman生成器一起使用RX

时间:2020-09-20 10:21:57

标签: javascript node.js typescript rxjs yeoman

根据文档查询者,我想将RXJS与typescript yeoman生成器一起使用,这是yeoman支持RXJS的引擎。

https://github.com/SBoudrias/Inquirer.js/#reactive-interface

I use the following 

export default class myGenerator extends Generator {

...

  async prompting() {
    const prompts = new Subject<Generator.Question>();
    await this.prompt(prompts);

    prompts.next({
      name: "appName",
      message: "app name: ",
      type: "input",
      default: this.props!.appName,
      validate(input: string) {
        const appName = validateAppName(input);
        return !appName[1] ? appName[0] : true;
      },
    });
    prompts.next({
      type: "list",
      name: "tech",
      message: "Which type",
      default: "CLI",
      choices: [{ name: "CLI" }, { name: "CloudApp" }],
    });



   
    prompts.complete();
}

现在运行它时出现错误:

Error: You must provide a `name` parameter
    at InputPrompt.throwParamError (/usr/local/lib/node_modules/yo/node_modules/inquirer/lib/prompts/base.js:73:11)
    at new Prompt (/usr/local/lib/node_modules/yo/node_modules/inquirer/lib/prompts/base.js:33:12)
    at new InputPrompt (/usr/local/lib/node_modules/yo/node_modules/inquirer/lib/prompts/input.js:11:1)
    at PromptUI.fetchAnswer (/usr/local/lib/node_modules/yo/node_modules/inquirer/lib/ui/prompt.js:85:25)
    at MergeMapSubscriber._tryNext (/usr/local/lib/node_modules/yo/node_modules/rxjs/internal/operators/mergeMap.js:69:27)
    at MergeMapSubscriber._next (/usr/local/lib/node_modules/yo/node_modules/rxjs/internal/operators/mergeMap.js:59:18)
    at MergeMapSubscriber.Subscriber.next (/usr/local/lib/node_modules/yo/node_modules/rxjs/internal/Subscriber.js:66:18)
    at MergeMapSubscriber.notifyNext (/usr/local/lib/node_modules/yo/node_modules/rxjs/internal/operators/mergeMap.js:95:26)
    at InnerSubscriber._next (/usr/local/lib/node_modules/yo/node_modules/rxjs/internal/InnerSubscriber.js:28:21)
    at InnerSubscriber.Subscriber.next (/usr/local/lib/node_modules/yo/node_modules/rxjs/internal/Subscriber.js:66:18)
events.js:170
      throw er; // Unhandled 'error' event

由于所有提示都提供了name属性,因此不确定将name放在哪里。 ,有什么主意吗?

我需要创建的是两个简单的问题,这些问题将与RXJS一起使用 我该怎么做?

0 个答案:

没有答案