sails-generate-entities
Version:
Sails.js generator for arbitrary entities
29 lines (24 loc) • 798 B
JavaScript
var path = require('path');
var _ = require('lodash');
module.exports = function (options) {
return {
before: function (scope, next) {
scope.module = options.module;
scope.id = options.id;
scope.createdAt = new Date();
next();
},
targets: _.extend(
_.object(options.statics, _.map(options.statics, function (entity) {
return { template: 'static.template.ejs' };
})),
_.object(options.classes, _.map(options.classes, function (entity) {
return { template: 'class.template.ejs' };
})),
_.object(options.functions, _.map(options.functions, function (entity) {
return { template: 'function.template.ejs' };
}))
),
templatesDirectory: require('path').resolve(__dirname, './templates')
};
};