From 77eb7a3188197e7899cfcb9773c8b410b74cfcfb Mon Sep 17 00:00:00 2001 From: RWOverdijk Date: Tue, 10 Oct 2017 12:07:08 +0200 Subject: [PATCH] feat(project): add default tempalte and modification generators --- lib/generator/ModificationGenerator.js | 22 ++++++++++++++++++++++ lib/generator/TemplateGenerator.js | 9 +++++++++ lib/generator/index.js | 4 ++++ 3 files changed, 35 insertions(+) create mode 100644 lib/generator/ModificationGenerator.js create mode 100644 lib/generator/TemplateGenerator.js create mode 100644 lib/generator/index.js diff --git a/lib/generator/ModificationGenerator.js b/lib/generator/ModificationGenerator.js new file mode 100644 index 0000000..fd7bf02 --- /dev/null +++ b/lib/generator/ModificationGenerator.js @@ -0,0 +1,22 @@ +const {Generator} = require('../Generator'); +const path = require('path'); + +class ModificationGenerator extends Generator { + prepare(parameters) { + parameters.targetDirectory = parameters.sourceDirectory; + parameters.targetFile = parameters.sourceFile + '.__tmp_replace'; + + parameters.move = { + sourceFile: path.join(parameters.sourceDirectory, parameters.targetFile), + targetFile: path.join(parameters.sourceDirectory, parameters.sourceFile) + }; + + return parameters; + } + + generate() { + return this.runSteps(['read', 'modify', 'write', 'move']); + } +} + +module.exports.ModificationGenerator = ModificationGenerator; diff --git a/lib/generator/TemplateGenerator.js b/lib/generator/TemplateGenerator.js new file mode 100644 index 0000000..d99d0d7 --- /dev/null +++ b/lib/generator/TemplateGenerator.js @@ -0,0 +1,9 @@ +const {Generator} = require('../Generator'); + +class TemplateGenerator extends Generator { + generate() { + return this.runSteps(['read', 'replace', 'write']); + } +} + +module.exports.TemplateGenerator = TemplateGenerator; diff --git a/lib/generator/index.js b/lib/generator/index.js new file mode 100644 index 0000000..e9cf286 --- /dev/null +++ b/lib/generator/index.js @@ -0,0 +1,4 @@ +module.exports = { + ModificationGenerator: require('./ModificationGenerator'), + TemplateGenerator : require('./TemplateGenerator'), +};