hexo
Version:
A fast, simple & powerful blog framework, powered by Node.js.
45 lines (37 loc) • 711 B
JavaScript
var ExtendError = require('../error').ExtendError;
/**
* This class is used to manage all generator plugins in Hexo.
*
* @class Generator
* @constructor
* @namespace Extend
* @module hexo
*/
var Generator = module.exports = function(){
/**
* @property store
* @type Array
*/
this.store = [];
};
/**
* Returns a list of generator plugins.
*
* @method list
* @return {Array}
*/
Generator.prototype.list = function(){
return this.store;
};
/**
* Registers a generator plugin.
*
* @method register
* @param {Function} fn
*/
Generator.prototype.register = function(fn){
if (typeof fn !== 'function'){
throw new ExtendError('Generator function is not defined');
}
this.store.push(fn);
};