From b78ad378c9221be65b6a2c78cb29201697d73c8f Mon Sep 17 00:00:00 2001 From: Sondre Nilsen Date: Tue, 23 Aug 2016 23:46:29 +0200 Subject: [PATCH] Create a new subgenerator to fix update command 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. --- generators/gulp/index.js | 12 ++++++++++++ generators/{jekyll => gulp}/templates/build.js | 0 generators/jekyll/index.js | 5 ----- generators/update/index.js | 6 ++++++ package.json | 1 + test/build.js | 14 ++++++++++++++ test/gulp.js | 1 - test/update/ghpages.js | 2 +- 8 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 generators/gulp/index.js rename generators/{jekyll => gulp}/templates/build.js (100%) create mode 100644 test/build.js diff --git a/generators/gulp/index.js b/generators/gulp/index.js new file mode 100644 index 0000000..475fabb --- /dev/null +++ b/generators/gulp/index.js @@ -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') + ); + } +}); diff --git a/generators/jekyll/templates/build.js b/generators/gulp/templates/build.js similarity index 100% rename from generators/jekyll/templates/build.js rename to generators/gulp/templates/build.js diff --git a/generators/jekyll/index.js b/generators/jekyll/index.js index de7477a..9746e64 100644 --- a/generators/jekyll/index.js +++ b/generators/jekyll/index.js @@ -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'), diff --git a/generators/update/index.js b/generators/update/index.js index e5718de..054c986 100644 --- a/generators/update/index.js +++ b/generators/update/index.js @@ -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 () { diff --git a/package.json b/package.json index 3f7ce57..a3417c8 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "space": true, "ignores": [ "generators/app/templates/**", + "generators/gulp/templates/**", "generators/jekyll/templates/**" ] } diff --git a/test/build.js b/test/build.js new file mode 100644 index 0000000..01a2e20 --- /dev/null +++ b/test/build.js @@ -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'); +}); diff --git a/test/gulp.js b/test/gulp.js index 2ebac66..04c98c2 100644 --- a/test/gulp.js +++ b/test/gulp.js @@ -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', diff --git a/test/update/ghpages.js b/test/update/ghpages.js index d75f02b..7fcc0f8 100644 --- a/test/update/ghpages.js +++ b/test/update/ghpages.js @@ -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);