Skip to content

Commit

Permalink
Add command to update your generator
Browse files Browse the repository at this point in the history
  • Loading branch information
sondr3 committed Jun 5, 2016
1 parent df8f278 commit 7f6ea43
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
52 changes: 52 additions & 0 deletions generators/update/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
'use strict';
var generators = require('yeoman-generator');

module.exports = generators.Base.extend({
constructor: function () {
generators.Base.apply(this, arguments);

this.option('skip-install', {
desc: 'Skip installing dependencies',
type: Boolean
});
},

prompting: function () {
var prompts = [{
name: 'babel',
type: 'confirm',
message: 'Compile your JS with Babel',
when: this.options.babel === undefined
}, {
name: 'uploading',
type: 'list',
message: 'How do you want to upload your site?',
choices: ['Amazon S3', 'Rsync', 'Github Pages', 'None'],
store: true
}];

return this.prompt(prompts).then(function (props) {
// To access props later use this.props.someAnswer;
this.props = props;
}.bind(this));
},

default: function () {
this.composeWith('jekyllized:gulp', {
options: {
uploading: this.props.uploading,
babel: this.props.babel
}
}, {
local: require.resolve('generator-statisk/generators/gulp')
});
},

install: function () {
this.installDependencies({
bower: false,
skipInstall: this.options['skip-install']
});
this.spawnCommand('bundle', ['install', '--quiet']);
}
});
8 changes: 5 additions & 3 deletions test/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ var helpers = require('yeoman-test');

test.before(() => {
var deps = [
[helpers.createDummyGenerator(), 'jekyllized:boilerplate'],
[helpers.createDummyGenerator(), 'jekyllized:jekyll'],
[helpers.createDummyGenerator(), 'jekyllized:gulp']
[helpers.createDummyGenerator(), 'statisk:git'],
[helpers.createDummyGenerator(), 'statisk:editorconfig'],
[helpers.createDummyGenerator(), 'statisk:gulp'],
[helpers.createDummyGenerator(), 'statisk:readme'],
[helpers.createDummyGenerator(), 'jekyllized:jekyll']
];

return helpers.run(path.join(__dirname, '../generators/app'))
Expand Down

0 comments on commit 7f6ea43

Please sign in to comment.