Skip to content

Commit

Permalink
feat(project): add default tempalte and modification generators
Browse files Browse the repository at this point in the history
  • Loading branch information
RWOverdijk committed Oct 10, 2017
1 parent cdc07b9 commit 77eb7a3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/generator/ModificationGenerator.js
Original file line number Diff line number Diff line change
@@ -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;
9 changes: 9 additions & 0 deletions lib/generator/TemplateGenerator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const {Generator} = require('../Generator');

class TemplateGenerator extends Generator {
generate() {
return this.runSteps(['read', 'replace', 'write']);
}
}

module.exports.TemplateGenerator = TemplateGenerator;
4 changes: 4 additions & 0 deletions lib/generator/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
ModificationGenerator: require('./ModificationGenerator'),
TemplateGenerator : require('./TemplateGenerator'),
};

0 comments on commit 77eb7a3

Please sign in to comment.