all files / js/ componentGenerator.js

86.67% Statements 13/15
100% Branches 0/0
50% Functions 2/4
86.67% Lines 13/15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39                                                   
'use strict';
 
let fse = require('fs-extra');
let path = require('path');
let moduleTplt = require('./templates/component/module').moduleTemplate;
let componentTplt = require('./templates/component/component').componentTemplate;
let controllerTplt = require('./templates/component/controller').controllerTemplate;
 
class ComponentGenerator {
 
  constructor(componentName) {
    this.componentName = componentName;
 
    this.filePath = path.join('src', 'ts', 'app', 'components', this.componentName);
 
    fse.mkdirsSync(this.filePath);
  }
 
  buildComponent() {
    this._createNewFiles();
 
    this._updateComponentsModule();
  }
 
  _createNewFiles() {
 
    fse.writeFileSync(path.join(this.filePath, `${this.componentName}.component.ts`), componentTplt(this.componentName));
    fse.writeFileSync(path.join(this.filePath, `${this.componentName}.controller.ts`), controllerTplt(this.componentName));
    fse.writeFileSync(path.join(this.filePath, `${this.componentName}.module.ts`), moduleTplt(this.componentName));
    fse.writeFileSync(path.join(this.filePath, `${this.componentName}.template.html`), '');
  }
 
  _updateComponentsModule() {
 
  }
 
}
 
module.exports = ComponentGenerator;