add generator and repeatString

This commit is contained in:
Cody Loyd
2017-08-21 10:28:29 -05:00
parent 85ca46440e
commit fd5b062516
21 changed files with 4116 additions and 0 deletions
@@ -0,0 +1,41 @@
'use strict';
const Generator = require('yeoman-generator');
const chalk = require('chalk');
const yosay = require('yosay');
module.exports = class extends Generator {
prompting() {
// Have Yeoman greet the user.
this.log(chalk.red('Let\'s do this'));
const prompts = [{
type: 'input',
name: 'title',
message: 'Enter the exercise title',
default: 'title'
}];
return this.prompt(prompts).then(props => {
// To access props later use this.props.someAnswer;
this.props = props;
});
}
writing() {
this.fs.copyTpl(
this.templatePath(`title.js`),
this.destinationPath(`${this.props.title}.js`),
{title: this.props.title}
);
this.fs.copyTpl(
this.templatePath(`title.spec.js`),
this.destinationPath(`${this.props.title}.spec.js`),
{title: this.props.title}
);
this.fs.copyTpl(
this.templatePath(`README.md`),
this.destinationPath(`README.md`),
{title: this.props.title}
);
}
};
@@ -0,0 +1,2 @@
# Exercise XX - <%= title %>
@@ -0,0 +1 @@
<%= title %>
@@ -0,0 +1,5 @@
var <%= title %> = function() {
}
module.exports = <%= title %>
@@ -0,0 +1,8 @@
var <%= title %> = require('./<%=title%>')
describe('<%=title%>', function() {
it('EDITME', function() {
expect(<%=title%>()).toEqual(' ');
});
});