Skip to content

Instantly share code, notes, and snippets.

@kristw
Last active August 1, 2016 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristw/61b154958bd31bbd299ff3182a7ae586 to your computer and use it in GitHub Desktop.
Save kristw/61b154958bd31bbd299ff3182a7ae586 to your computer and use it in GitHub Desktop.
An example generator with yeoman-easily
var ye = require('yeoman-easily');
var Easily = ye.Easily;
var commonPrompts = ye.prompts;
var chalk = require('chalk');
module.exports = Easily.createGenerator({
prompting: function () {
return this.easily
.greet('Welcome to the awesome generator!')
.confirmBeforeStart('Would you like to use bower?')
.learnPrompts(commonPrompts)
.prompt([
'name',
'description',
'authorName',
'authorEmail',
'authorUrl',
'githubAccount'
], true);
},
writing: function () {
if (this.easily.checkForConfirmation()) {
this.easily
.extendJSONWithTemplate(
'__package.json',
'package.json',
this.props
)
.extendJSONWithTemplate(
'__bower.json',
'bower.json',
this.props
)
.copyFiles('**/*', {
ignore: '**/__*',
dynamicFiles: [
'src/index.html',
'README.md'
],
props: props
})
.composeWithExternal(
'generator-license',
'license:app',
{
name: this.props.authorName,
email: this.props.authorEmail,
website: this.props.authorUrl
}
);
}
},
install: function () {
this.installDependencies();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment