UNPKG

jmms

Version:

Jmms cli tools, Jmms is a java meta-micro-service framework

32 lines (25 loc) 857 B
const _ = require('lodash'); const log = require('../../log'); const fs = require('fs'); const path = require('path'); var BaseGenerator = require('../../base'); module.exports = class extends BaseGenerator { constructor(args, opts) { super(args, opts); } initializing() { this.entityName = _.upperFirst(this.options.name); this.entityPath = this.app.entityPath(this.entityName + ".json"); if(fs.existsSync(this.entityPath)) { log.warn(`Entity '${this.entityName}' already exists at '${this.entityPath}`); process.exit(0); } } writing() { const vars = {name: this.entityName}; this.fs.copyTpl(this.templatePath('./Entity.json'), this.entityPath, vars); } end() { log.success(`Entity '${this.entityName}' created!`); } };