我正在尝试构建一个简单的yeoman任务,该任务将模板目录复制到用户运行命令的目标目录。prompt方法正在工作,但没有写入或复制任何内容。你知道我哪里错了吗?
'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')
);
}
};发布于 2017-06-13 13:26:46
从1.0版本开始,prompt方法不再接受回调
相反,您想要this.prompt([...]).then(callback)
https://stackoverflow.com/questions/44501357
复制相似问题