Skip to content

Commit

Permalink
Fix name and version of generator being applied
Browse files Browse the repository at this point in the history
Now it manages to properly add the generators name and version to the
gulpfile instead of just leaving it blank.
  • Loading branch information
sondr3 committed Jun 6, 2016
1 parent 43b383d commit 5eef5df
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 4 additions & 2 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var chalk = require('chalk');
var generators = require('yeoman-generator');
var shelljs = require('shelljs');
var yosay = require('yosay');
var pkg = require('../../package.json');

module.exports = generators.Base.extend({
constructor: function () {
Expand Down Expand Up @@ -34,7 +35,6 @@ module.exports = generators.Base.extend({
},

initializing: function () {
this.props = {};
this.pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
},

Expand Down Expand Up @@ -156,8 +156,10 @@ on Github](https://github.com/sondr3/generator-jekyllized).
local: require.resolve('generator-statisk/generators/readme')
});

this.composeWith('jekyllized:gulp', {
this.composeWith('statisk:gulp', {
options: {
name: pkg.name,
version: pkg.version,
uploading: this.props.uploading,
babel: this.props.babel
}
Expand Down
15 changes: 13 additions & 2 deletions test/gulp.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ var assert = require('yeoman-assert');
var helpers = require('yeoman-test');

test.before(() => {
var pkg = require('../package.json');

var deps = [
[helpers.createDummyGenerator(), 'statisk:gulp']
];

return helpers.run(path.join(__dirname, '../generators/app'))
.withOptions({uploading: 'None'})
.withOptions({
name: pkg.name,
version: pkg.version,
uploading: 'None'
})
.withGenerators(deps)
.toPromise();
});
Expand All @@ -23,6 +29,12 @@ test('creates package.json', () => {
assert.file('package.json');
});

test('creates comment about creation', () => {
const pkg = require('../package.json');
const date = (new Date).toISOString().split('T')[0]; // eslint-disable-line
assert.fileContent('gulpfile.js', '// generated on ' + date + ' using ' + pkg.name + ' ' + pkg.version);
});

test('creates gulp task files', () => {
assert.file([
'gulp/tasks/browsersync.js',
Expand All @@ -38,4 +50,3 @@ test('creates gulp task files', () => {
'gulp/tasks/uploading.js'
]);
});

0 comments on commit 5eef5df

Please sign in to comment.