1
我在摆弄yeoman,想写一个简单的html5样板的第一个生成器。我的问题是,我的发电机中的两个功能单独工作,但不在一起,我不知道为什么。我从yeoman页面查看了一些生成器,但是我没有看到我做错了什么。我希望你能帮助我。这是我的代码:Yeoman复制功能在提示后不起作用
'use strict';
var generators = require('yeoman-generator');
var yosay = require('yosay');
module.exports = generators.Base.extend({
initializing: function(){
this.log(yosay("\'Allo \'allo I will create your HTML5 Boilerplate..."));
},
prompting: function() {
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: function(){
this.fs.copyTpl(
this.templatePath('_page/_index.html'),
this.destinationPath('index.html'),
{ title: "answers.name" }
);
},
});
在此先感谢!
谢谢,但这不是:-(工作......控制台提供了一个错误“对象的翻译:有没有方法‘然后’” ......我我试图更新yeoman生成器,但是错误仍然存在,我没有那么习惯承诺,但为什么其他生成器不工作,不使用承诺? – sonnenpriester
没有承诺的旧语法仍然可行 - 它只是可能比较新的方法更不可靠为了更好地了解发生了什么,你可以尝试将'this'记录到控制台 - 'this'应该指向整个生成器对象,如果不是,那可能是源码你的问题。 – Deimyts