Skip to content

Commit a43aed0

Browse files
committed
Refactored generators to properly extend the base generator class
1 parent c95af7b commit a43aed0

File tree

7 files changed

+33
-25
lines changed

7 files changed

+33
-25
lines changed

generators/action/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const Generator = require('yeoman-generator');
33
const walk = require('esprima-walk');
44
const utils = require('../app/utils');
55

6-
module.exports = class extends Generator {
6+
class ActionGenerator extends Generator {
77
constructor(args, opts) {
88
super(args, opts);
99
this.argument('name', { type: String, required: true });
@@ -127,3 +127,5 @@ module.exports = class extends Generator {
127127
this.attachToApp(appPath, baseName);
128128
}
129129
};
130+
131+
module.exports = ActionGenerator;

generators/app/index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
'use strict';
2-
let generator = require('yeoman-generator');
2+
const Generator = require('yeoman-generator');
33

4-
module.exports = generator.Base.extend({
5-
6-
constructor: function() {
7-
generator.Base.apply(this, arguments);
4+
class AppGenerator extends Generator {
85

6+
constructor(args, opts) {
7+
super(args, opts);
98
this.option('skip-install');
10-
},
11-
12-
install: function() {
9+
}
1310

11+
install() {
1412
if(!this.options['skip-install']) {
1513
this.installDependencies({ bower: false });
1614
}
1715

1816
// Run the base react-webpack generator, then run the dispatcher
1917
this.composeWith(
20-
'react-webpack',
18+
'generator-react-webpack',
2119
{
2220
options: {
2321
'skip-install': this.options['skip-install']
@@ -38,4 +36,6 @@ module.exports = generator.Base.extend({
3836
this.npmInstall(['redux', 'react-redux'], { 'save': true });
3937
});
4038
}
41-
});
39+
};
40+
41+
module.exports = AppGenerator;

generators/component/index.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
'use strict';
2-
let generator = require('yeoman-generator');
2+
const Generator = require('yeoman-generator');
33

4-
module.exports = generator.Base.extend({
4+
module.exports = class ComponentGenerator extends Generator {
55

6-
constructor: function() {
6+
constructor() {
77
generator.Base.apply(this, arguments);
88
this.argument('name', { type: String, required: true });
9-
},
10-
11-
writing: function() {
9+
}
1210

11+
writing() {
1312
// Build options
1413
let opts = {};
1514

@@ -19,9 +18,9 @@ module.exports = generator.Base.extend({
1918

2019
this.composeWith('react-webpack', {
2120
options: opts,
22-
args: [ this.name ]
21+
args: [ this.options.name ]
2322
}, {
2423
local: require.resolve('generator-react-webpack/generators/component')
2524
});
2625
}
27-
});
26+
};

generators/container/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
const Generator = require('yeoman-generator');
33
const utils = require('../app/utils');
44

5-
module.exports = class extends Generator {
5+
class ContainerGenerator extends Generator {
66

77
constructor(args, opts) {
88
super(args, opts);
@@ -26,3 +26,5 @@ module.exports = class extends Generator {
2626
);
2727
}
2828
};
29+
30+
module.exports = ContainerGenerator;

generators/reducer/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const path = require('path');
44
const walk = require('esprima-walk');
55
const utils = require('../app/utils');
66

7-
module.exports = class extends Generator {
7+
class ReducerGenerator extends Generator {
88
constructor(args, opts) {
99
super(args, opts);
1010
this.argument('name', { type: String, required: true });
@@ -147,3 +147,5 @@ module.exports = class extends Generator {
147147
this.attachToApp(appPath, baseName);
148148
}
149149
};
150+
151+
module.exports = ReducerGenerator;

generators/root/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
const Generator = require('yeoman-generator');
33
const fs = require('fs');
44

5-
module.exports = class extends Generator {
5+
class RootGenerator extends Generator {
66

7+
/*
78
constructor(args, opts) {
8-
super(args, opts); // eslint-disable-line prefer-rest-params
9-
this.argument('name', { type: String, required: true });
9+
super(args, opts);
1010
}
11+
*/
1112

1213
writing() {
1314
/* Some base functionality needs to be overwritten, so we force yeoman to do
@@ -59,3 +60,5 @@ module.exports = class extends Generator {
5960
);
6061
}
6162
};
63+
64+
module.exports = RootGenerator;

test/generators/container/indexTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('react-webpack-redux:container', () => {
1717
.on('end', callback);
1818
}
1919

20-
describe('When creating a new action', () => {
20+
describe('When creating a new container', () => {
2121

2222
it('should create the container file', (done) => {
2323
createGeneratedContainer('TestContainer', () => {

0 commit comments

Comments
 (0)