Skip to content

Commit 5eef5df

Browse files
committed
Fix name and version of generator being applied
Now it manages to properly add the generators name and version to the gulpfile instead of just leaving it blank.
1 parent 43b383d commit 5eef5df

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

generators/app/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var chalk = require('chalk');
55
var generators = require('yeoman-generator');
66
var shelljs = require('shelljs');
77
var yosay = require('yosay');
8+
var pkg = require('../../package.json');
89

910
module.exports = generators.Base.extend({
1011
constructor: function () {
@@ -34,7 +35,6 @@ module.exports = generators.Base.extend({
3435
},
3536

3637
initializing: function () {
37-
this.props = {};
3838
this.pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
3939
},
4040

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

159-
this.composeWith('jekyllized:gulp', {
159+
this.composeWith('statisk:gulp', {
160160
options: {
161+
name: pkg.name,
162+
version: pkg.version,
161163
uploading: this.props.uploading,
162164
babel: this.props.babel
163165
}

test/gulp.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@ var assert = require('yeoman-assert');
55
var helpers = require('yeoman-test');
66

77
test.before(() => {
8+
var pkg = require('../package.json');
9+
810
var deps = [
911
[helpers.createDummyGenerator(), 'statisk:gulp']
1012
];
1113

1214
return helpers.run(path.join(__dirname, '../generators/app'))
13-
.withOptions({uploading: 'None'})
15+
.withOptions({
16+
name: pkg.name,
17+
version: pkg.version,
18+
uploading: 'None'
19+
})
1420
.withGenerators(deps)
1521
.toPromise();
1622
});
@@ -23,6 +29,12 @@ test('creates package.json', () => {
2329
assert.file('package.json');
2430
});
2531

32+
test('creates comment about creation', () => {
33+
const pkg = require('../package.json');
34+
const date = (new Date).toISOString().split('T')[0]; // eslint-disable-line
35+
assert.fileContent('gulpfile.js', '// generated on ' + date + ' using ' + pkg.name + ' ' + pkg.version);
36+
});
37+
2638
test('creates gulp task files', () => {
2739
assert.file([
2840
'gulp/tasks/browsersync.js',
@@ -38,4 +50,3 @@ test('creates gulp task files', () => {
3850
'gulp/tasks/uploading.js'
3951
]);
4052
});
41-

0 commit comments

Comments
 (0)