Yeoman发电机没有输出任何东西

时间:2018-02-12 04:54:31

标签: command-line-interface yeoman yeoman-generator

我正在尝试编写一个非常基本的生成器,它将创建与组件相关的4个文件。此时所有生成器需要从命令行获取组件名称,然后创建具有该名称的4个文件。发电机运行良好,但在完成后没有做任何事情。

my index.js/app

'use strict';
//Require dependencies
var chalk = require('chalk');
var yosay = require('yosay');
var Generator = require('yeoman-generator');

module.exports = class extends Generator {
    prompting() {
      var done = this.async();
      this.prompt({
        type: 'input',
        name: 'componentName',
        message: 'Your component name',
        default: this.appname
      }, (answers) => {
        this.props = answers
      });
    }

    writing() {
        const componentName = this.props.componentName;

        this.fs.copyTpl(
            `${this.templatePath()}/**/!(_)*`,
            this.destinationPath(),
            this.props
        );

        this.fs.copyTpl(
            this.templatePath('src/_component.js'),
            this.destinationPath(`${componentName}.js`),
            this.props
        );

        this.fs.copyTpl(
            this.templatePath('src/_component.spec.js'),
            this.destinationPath(`${componentName}.spec.js`),
            this.props
        );

        this.fs.copyTpl(
            this.templatePath('src/_component.scss'),
            this.destinationPath(`${componentName}.scss`),
            this.props
        );

        this.fs.copyTpl(
            this.templatePath('src/_component.pug'),
            this.destinationPath(`${componentName}.pug`),
            this.props
        );
    }

    install() {
        this.installDependencies();
    }
};

1 个答案:

答案 0 :(得分:0)

要输出内容,请使用this.log("your message")。您可以在end()函数中使用它来通知用户生成是竞争的

相关问题