2017-06-12 43 views
0

我想构建一个简单的yeoman任务,将模板目录复制到用户运行命令的目标目录中。提示方法正在运行,但没有任何内容正在写入或复制。任何想法,我哪里错了?Yeoman任务不复制目录

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

module.exports = class extends yeoman { 
    //Ask for user input 
    prompting() { 
     var done = this.async(); 
     this.prompt({ 
      type: 'input', 
      name: 'name', 
      message: 'Your project name', 
      //Defaults to the project's folder name if the input is skipped 
      default: this.appname 
     }, function(answers) { 
      this.props = answers 
      this.log(answers.name); 
      done(); 
     }.bind(this)); 
    } 

    //Writing Logic here 
    writing() { 
     this.fs.copyTpl(
      this.templatePath('testfile'), 
      this.destinationPath('testfile') 
     ); 
    } 
}; 

回答

0

提示方法并不需要一个回调,因为发行1.0

相反,你要this.prompt([...]).then(callback)