grunt を起動しようとしたときに、HTML テンプレート プロジェクト用の yoeman ジェネレーターを作成したい
$> grunt
Loading "Gruntfile.js" tasks...ERROR
>> ReferenceError: grunt is not defined
Warning: Task "default" not found. Use --force to continue.
Aborted due to warnings.
これが私のコードです
var fs = require('fs');
var path = require('path');
var showdown = require('showdown');
var EJS = require('ejs');
var TemplateRender = function(file, destination, source, template) {
this.file = file;
this.destination = destination;
this.source = source;
this.template = template;
this.grunt = grunt;
};
TemplateRender.prototype = {
render: function() {
var file = this._read();
var html = this._convert(file);
var content = this._template(html);
this._write(content);
},
_read: function() {
var filepath = path.join(this.source,this.file);
grunt.file.read(filepath);
},
_convert: function(file) {
return new showdown.convertor().makeHtml(file);
},
_template: function(html) {
var template = this.grunt.file.read(this.template);
return EJS.render(template,{content:html});
},
_write: function() {
this.grunt.file.write(
path.join(this.destination, this.file),
page
);
}
};
'use strict';
module.exports = function(grunt) {
grunt.registerTask('build', function() {
var template = "app/index.ejs",
destination = path.join(process.cwd(),"dist"),
source = path.join(process.cwd(),"posts"),
files = fs.readdirSync(source);
files.forEach(function(file) {
new TemplateRender(file, destination, source, template, grunt).render();
read();
convert();
template();
write();
});
});
};
grunt と yeoman のエラーを検出する方法を知る必要があります