Yeoman任务没有复制目录

时间:2017-06-12 14:01:46

标签: javascript yeoman yeoman-generator

我正在尝试构建一个简单的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')
        );
    }
};

1 个答案:

答案 0 :(得分:0)

自1.0版以来,提示方法不进行回调

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