Skip to content

Commit e808105

Browse files
BrianSippleSBoudrias
authored andcommitted
convert default generator to an ES2015-style class
1 parent 67cd96e commit e808105

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

subgenerator/templates/index.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
'use strict';
2-
var Generator = require('yeoman-generator');
3-
var chalk = require('chalk');
4-
var yosay = require('yosay');
2+
const Generator = require('yeoman-generator');
3+
const chalk = require('chalk');
4+
const yosay = require('yosay');
55

6-
module.exports = Generator.extend({
7-
prompting: function () {
6+
module.exports = class extends Generator {
7+
prompting() {
88
// Have Yeoman greet the user.
99
this.log(yosay(
1010
'Welcome to the <%- superb %> ' + chalk.red('<%= generatorName %>') + ' generator!'
1111
));
1212

13-
var prompts = [{
13+
const prompts = [{
1414
type: 'confirm',
1515
name: 'someAnswer',
1616
message: 'Would you like to enable this option?',
1717
default: true
1818
}];
1919

20-
return this.prompt(prompts).then(function (props) {
20+
return this.prompt(prompts).then(props => {
2121
// To access props later use this.props.someAnswer;
2222
this.props = props;
23-
}.bind(this));
24-
},
23+
});
24+
}
2525

26-
writing: function () {
26+
writing() {
2727
this.fs.copy(
2828
this.templatePath('dummyfile.txt'),
2929
this.destinationPath('dummyfile.txt')
3030
);
31-
},
31+
}
3232

33-
install: function () {
33+
install() {
3434
this.installDependencies();
3535
}
36-
});
36+
};

0 commit comments

Comments
 (0)