【问题标题】:yeoman-generator paused after promptyeoman-generator 在提示后暂停
【发布时间】:2026-02-12 06:55:02
【问题描述】:

我正在尝试编写一个生成器。 在终端打印app name 后暂停。

如何让它执行copyFile动作?

var Generator = require('yeoman-generator');

module.exports = class extends Generator {
  // The name `constructor` is important here
  constructor(args, opts) {
    // Calling the super constructor is important so our generator is correctly set up
    super(args, opts);

    this.argument("proname", {
      type: String,
      required: true
    });
  }

  askFor() {
    const done = this.async();

    this.prompt([{
      type: "input",
      name: "name",
      message: "Your crx name",
      default: 'myCrx' // Default to current folder name
    }, {
      name: 'description',
      message: 'How would you like to describe this extension?',
      default: 'My Chrome Extension'
    }
    ]).then(function (answers){
      this.log("app name", answers.name); 
      this.name = answers.name.replace(/\"/g, '\\"');
      done();
    }.bind(this));
  }

  copyFile() {
    this.log('Creating templates');
    this.fs.copy(
      this.templatePath('./'),
      this.destinationPath('./' + this.options.proname)
    );
  }

};

【问题讨论】:

    标签: yeoman yeoman-generator


    【解决方案1】:

    从 2.x 更新 yo@^3.3.1 解决了这个问题。

    【讨论】: