Skip to content

Commit

Permalink
Merge branch 'feature/#14-multiple-modules' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Herweg committed Aug 12, 2018
2 parents 32d51c5 + db58bd8 commit 668e427
Show file tree
Hide file tree
Showing 8 changed files with 7,329 additions and 397 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change log

## Ferdi v 0.0.15 - 2018-08-12

* Added functionality to add multiple Files see [#14];

## Ferdi v 0.0.10 - 2018-01-12

* Added --flat option to create components without a subfolder.
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ defaults: {
Every time you add a new component without any flags these default files are created (template, css and js in this case). The key must be the same as in the files Object.
Every key in the files Object must also be in the defaults Object.

### Multiple "Components"
If you want to add multiple Components with the same options you can do that by writing `ferdi foo bar --option` this creates a `foo` and a `bar` component

### files

This is where the 'magic' happens, ferdi create a new entry for every file type you wish to have a boilerplate for.
Expand Down
21 changes: 13 additions & 8 deletions __tests__/__snapshots__/createModule.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,23 @@ exports[`ferdi --help : ferdi --help stdout 1`] = `
init Copy the Config File to current Folder
copy Copy Example Templates to your Project
Path Options
File Options
--template ferdi creates a template
--css ferdi creates a css
--javascript ferdi creates a javascript
--vue ferdi creates a vue
--vuexModule ferdi creates a vuexModule
--fractal ferdi creates a fractal
Path Options
--atomic, -a ferdi creates File at src/atomic/
--modules, -m ferdi creates File at src/modules/
Options:
--version Show version number [boolean]
--template ferdi should create a Template File
--css ferdi should create Stylesheet File
--javascript ferdi should create JavaScript File
--flat Create component Files in the Folder itself and not in a
component named subfolder
--help Show help [boolean]
--version Show version number [boolean]
--flat Create component Files in the Folder itself and not in a component
named subfolder
--help Show help [boolean]
"
`;
33 changes: 33 additions & 0 deletions __tests__/createModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,39 @@ describe('Create new Module', () => {
});
});



describe('create multiple modules with the same options', () => {
test('it should create multiple modules with same settings if multiple module names are provided', () => {
const moduleName = 'buttonFoo buttonBar buttonBaz';
return runCli(`${moduleName} -m`, '../src').then(stdout => {
const basePath = `./src/${config.paths.modulePath + config.paths.pathOptions.modules}`;

const modules = moduleName.split(' ');

modules.forEach(module => {
assert.file([`${basePath + module}/_${module}-style.scss`]);
assert.file([`${basePath + module}/${module}-template.html`]);
assert.file([`${basePath + module}/${module}-script.js`]);
});
});
});

test('it should create multiple modules with same settings in same dir if multiple Modulesa are provided with --flat option', () => {
const moduleName = 'buttonFoo buttonBar buttonBaz';
return runCli(`${moduleName} -m --flat`, '../src').then(stdout => {
console.log(stdout);
const basePath = `./src/${config.paths.modulePath + config.paths.pathOptions.modules}`;

const modules = moduleName.split(' ');

modules.forEach(module => {
assert.file([`${basePath}_${module}-style.scss`, `${basePath}${module}-template.html`, `${basePath}${module}-script.js`]);
});
});
});
});

function runCli(args = '', cwd = process.cwd()) {
const isRelative = cwd[0] !== '/';

Expand Down
Loading

0 comments on commit 668e427

Please sign in to comment.