Skip to content

Commit

Permalink
Create a new subgenerator to fix update command
Browse files Browse the repository at this point in the history
Now it will correctly update all the gulp task files and not just the ones used
in `generator-statisk`. Also fixed a small issue with a typo in a test.

Should be the final fix needed for #141. Closes #141.
  • Loading branch information
sondr3 committed Aug 23, 2016
1 parent c02cc5d commit b78ad37
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 7 deletions.
12 changes: 12 additions & 0 deletions generators/gulp/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

var generators = require('yeoman-generator');

module.exports = generators.Base.extend({
writing: function () {
this.fs.copy(
this.templatePath('build.js'),
this.destinationPath('gulp/tasks/build.js')
);
}
});
File renamed without changes.
5 changes: 0 additions & 5 deletions generators/jekyll/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ module.exports = generators.Base.extend({
this.destinationPath('Gemfile')
);

this.fs.copy(
this.templatePath('build.js'),
this.destinationPath('gulp/tasks/build.js')
);

this.fs.copyTpl(
this.templatePath('config.yml'),
this.destinationPath('_config.yml'),
Expand Down
6 changes: 6 additions & 0 deletions generators/update/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ module.exports = generators.Base.extend({
}, {
local: require.resolve('generator-statisk/generators/gulp')
});

this.composeWith('jekyllized:gulp', {
options: {}
}, {
local: require.resolve('../gulp')
});
},

install: function () {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"space": true,
"ignores": [
"generators/app/templates/**",
"generators/gulp/templates/**",
"generators/jekyll/templates/**"
]
}
Expand Down
14 changes: 14 additions & 0 deletions test/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

var path = require('path');
var test = require('ava');
var assert = require('yeoman-assert');
var helpers = require('yeoman-test');

test.before(() => {
return helpers.run(path.join(__dirname, '../generators/gulp'))
.toPromise();
});

test('creates gulp file for building jekyll', () => {
assert.file('gulp/tasks/build.js');
});
1 change: 0 additions & 1 deletion test/gulp.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ test('creates comment about creation', () => {
test('creates gulp task files', () => {
assert.file([
'gulp/tasks/assets.js',
'gulp/tasks/build.js',
'gulp/tasks/clean.js',
'gulp/tasks/copy.js',
'gulp/tasks/fonts.js',
Expand Down
2 changes: 1 addition & 1 deletion test/update/ghpages.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ test('does not contain wrong uploading packages', () => {
test('contains deploy function', () => {
[
'const gulp',
'const ghpages',
'const ghPages',
'gulp.task(\'upload'
].forEach(field => {
assert.fileContent('gulp/tasks/uploading.js', field);
Expand Down

0 comments on commit b78ad37

Please sign in to comment.