Skip to content

Commit 7f6ea43

Browse files
committed
Add command to update your generator
1 parent df8f278 commit 7f6ea43

File tree

2 files changed

+57
-3
lines changed

2 files changed

+57
-3
lines changed

generators/update/index.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
'use strict';
2+
var generators = require('yeoman-generator');
3+
4+
module.exports = generators.Base.extend({
5+
constructor: function () {
6+
generators.Base.apply(this, arguments);
7+
8+
this.option('skip-install', {
9+
desc: 'Skip installing dependencies',
10+
type: Boolean
11+
});
12+
},
13+
14+
prompting: function () {
15+
var prompts = [{
16+
name: 'babel',
17+
type: 'confirm',
18+
message: 'Compile your JS with Babel',
19+
when: this.options.babel === undefined
20+
}, {
21+
name: 'uploading',
22+
type: 'list',
23+
message: 'How do you want to upload your site?',
24+
choices: ['Amazon S3', 'Rsync', 'Github Pages', 'None'],
25+
store: true
26+
}];
27+
28+
return this.prompt(prompts).then(function (props) {
29+
// To access props later use this.props.someAnswer;
30+
this.props = props;
31+
}.bind(this));
32+
},
33+
34+
default: function () {
35+
this.composeWith('jekyllized:gulp', {
36+
options: {
37+
uploading: this.props.uploading,
38+
babel: this.props.babel
39+
}
40+
}, {
41+
local: require.resolve('generator-statisk/generators/gulp')
42+
});
43+
},
44+
45+
install: function () {
46+
this.installDependencies({
47+
bower: false,
48+
skipInstall: this.options['skip-install']
49+
});
50+
this.spawnCommand('bundle', ['install', '--quiet']);
51+
}
52+
});

test/app.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ var helpers = require('yeoman-test');
66

77
test.before(() => {
88
var deps = [
9-
[helpers.createDummyGenerator(), 'jekyllized:boilerplate'],
10-
[helpers.createDummyGenerator(), 'jekyllized:jekyll'],
11-
[helpers.createDummyGenerator(), 'jekyllized:gulp']
9+
[helpers.createDummyGenerator(), 'statisk:git'],
10+
[helpers.createDummyGenerator(), 'statisk:editorconfig'],
11+
[helpers.createDummyGenerator(), 'statisk:gulp'],
12+
[helpers.createDummyGenerator(), 'statisk:readme'],
13+
[helpers.createDummyGenerator(), 'jekyllized:jekyll']
1214
];
1315

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

0 commit comments

Comments
 (0)