功夫不负有心人

问题描述 投票:0回答:1

我想写一个生成器,打印完后就暂停了。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个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.