Skip to content

Commit

Permalink
feat(project): add CopyGenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
Wesley Overdijk committed Apr 12, 2018
1 parent d78f287 commit 5168e13
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@ This is probably the easiest a generator gets. It runs the following steps:
This generator is useful for copying template files into your project.
Because the replace step uses Procurator for templating, you can make your templates dynamic.

#### CopyGenerator

```js
const {CopyGenerator} = require('boards');
```

This generator performs a quick and easy copy using the following steps:

- read
- write

This generator is useful for copying static files into your project (think assets, images etc).

#### ModificationGenerator

```js
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ const {Boards} = require('./lib/Boards');
const {Generator} = require('./lib/Generator');
const {ModificationGenerator} = require('./lib/generator/ModificationGenerator');
const {TemplateGenerator} = require('./lib/generator/TemplateGenerator');
const {CopyGenerator} = require('./lib/generator/CopyGenerator');

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

class CopyGenerator extends Generator {
prepare(parameters) {
parameters.targetDirectory = parameters.sourceDirectory;
parameters.targetFile = parameters.sourceFile;

parameters.move = {
sourceFile: path.join(parameters.sourceDirectory, parameters.targetFile),
targetFile: path.join(parameters.sourceDirectory, parameters.sourceFile)
};

return parameters;
}

generate() {
return this.runSteps(['read', 'write']);
}
}

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

0 comments on commit 5168e13

Please sign in to comment.