Skip to content

Commit 19ea966

Browse files
committed
Fix tests, update yeoman-generator
Updated to use the JSONFileContent function in yeoman-assert for checking package.json. Also updated the syntax in the default generator so it works with the new version of yeoman-generator.
1 parent fa9e6b1 commit 19ea966

File tree

7 files changed

+81
-80
lines changed

7 files changed

+81
-80
lines changed

generators/app/index.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
var _ = require('lodash');
44
var chalk = require('chalk');
55
var generators = require('yeoman-generator');
6-
var yosay = require('yosay');
76
var shelljs = require('shelljs');
87

98
module.exports = generators.Base.extend({
@@ -32,13 +31,7 @@ module.exports = generators.Base.extend({
3231
},
3332

3433
prompting: function () {
35-
var done = this.async();
36-
37-
if (!this.options['skip-welcome-message']) {
38-
this.log(yosay('\'Allo \'allo!'));
39-
}
40-
41-
var prompts = [{
34+
var questions = [{
4235
name: 'projectName',
4336
message: 'What is the name of your project?',
4437
store: true
@@ -93,10 +86,8 @@ module.exports = generators.Base.extend({
9386
store: true
9487
}];
9588

96-
this.prompt(prompts, function (props) {
97-
this.props = _.extend(this.props, props);
98-
99-
done();
89+
return this.prompt(questions).then(function (props) {
90+
this.props = props;
10091
}.bind(this));
10192
},
10293

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
"lodash": "^4.11.1",
2525
"shelljs": "^0.7.0",
2626
"yargs": "^4.6.0",
27-
"yeoman-generator": "^0.23.3",
28-
"yosay": "^1.1.1"
27+
"yeoman-generator": "^0.23.3"
2928
},
3029
"devDependencies": {
3130
"ava": "^0.14.0",
@@ -38,6 +37,9 @@
3837
},
3938
"xo": {
4039
"space": true,
40+
"rules": {
41+
"new-cap": 0
42+
},
4143
"ignores": [
4244
"generators/app/templates/**",
4345
"generators/boilerplate/templates/**",

test/gulp.js

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,34 @@ test('creates package.json', () => {
1919
});
2020

2121
test('package.json contains correct packages', () => {
22-
[
23-
'"autoprefixer": "^6.2.3"',
24-
'"browser-sync": "^2.11.0"',
25-
'"del": "^2.2.0"',
26-
'"gulp": "git://github.com/gulpjs/gulp.git#4.0"',
27-
'"gulp-cache": "^0.4.1"',
28-
'"gulp-concat": "^2.6.0"',
29-
'"gulp-cssnano": "^2.1.0"',
30-
'"gulp-eslint": "^2.0.0"',
31-
'"gulp-gzip": "^1.1.0"',
32-
'"gulp-htmlmin": "^1.3.0"',
33-
'"gulp-if": "^2.0.0"',
34-
'"gulp-imagemin": "^2.1.0"',
35-
'"gulp-inject": "^4.0.0"',
36-
'"gulp-load-plugins": "^1.2.0"',
37-
'"gulp-newer": "^1.1.0"',
38-
'"gulp-postcss": "^6.0.0"',
39-
'"gulp-rename": "^1.2.2"',
40-
'"gulp-rev": "^7.0.0"',
41-
'"gulp-sass": "^2.1.1"',
42-
'"gulp-size": "^2.0.0"',
43-
'"gulp-sourcemaps": "^1.3.0"',
44-
'"gulp-uglify": "^1.5.1"',
45-
'"gulp-uncss": "^1.0.0"',
46-
'"shelljs": "^0.6.0"',
47-
'"yargs": "^4.3.2"'
48-
].forEach(pack => {
49-
assert.fileContent('package.json', pack);
22+
assert.JSONFileContent('package.json', {
23+
devDependencies: {
24+
'autoprefixer': '^6.2.3',
25+
'browser-sync': '^2.11.0',
26+
'del': '^2.2.0',
27+
'gulp': 'git://github.com/gulpjs/gulp.git#4.0',
28+
'gulp-cache': '^0.4.1',
29+
'gulp-concat': '^2.6.0',
30+
'gulp-cssnano': '^2.1.0',
31+
'gulp-eslint': '^2.0.0',
32+
'gulp-gzip': '^1.1.0',
33+
'gulp-htmlmin': '^1.3.0',
34+
'gulp-if': '^2.0.0',
35+
'gulp-imagemin': '^2.1.0',
36+
'gulp-inject': '^4.0.0',
37+
'gulp-load-plugins': '^1.2.0',
38+
'gulp-newer': '^1.1.0',
39+
'gulp-postcss': '^6.0.0',
40+
'gulp-rename': '^1.2.2',
41+
'gulp-rev': '^7.0.0',
42+
'gulp-sass': '^2.1.1',
43+
'gulp-size': '^2.0.0',
44+
'gulp-sourcemaps': '^1.3.0',
45+
'gulp-uglify': '^1.5.1',
46+
'gulp-uncss': '^1.0.0',
47+
'shelljs': '^0.6.0',
48+
'yargs': '^4.3.2'
49+
}
5050
});
5151
});
5252

@@ -58,13 +58,13 @@ test('does not create credentials files', () => {
5858
});
5959

6060
test('does not contain uploading packages', () => {
61-
[
62-
'"gulp-awspublish"',
63-
'"concurrent-transform"',
64-
'"gulp-rsync"',
65-
'"gulp-gh-pages"'
66-
].forEach(pack => {
67-
assert.noFileContent('package.json', pack);
61+
assert.noJSONFileContent('package.json', {
62+
devDependencies: {
63+
'gulp-awspublish': '^3.0.1',
64+
'concurrent-transform': '^1.0.0',
65+
'gulp-rsync': '^0.0.5',
66+
'gulp-gh-pages': '^0.5.2'
67+
}
6868
});
6969
});
7070

test/uploading/aws.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ test('creates package.json file', () => {
1919
});
2020

2121
test('contain correct uploading packages', () => {
22-
[
23-
'"gulp-awspublish": "^3.0.1"',
24-
'"concurrent-transform": "^1.0.0"'
25-
].forEach(pack => {
26-
assert.fileContent('package.json', pack);
22+
assert.JSONFileContent('package.json', {
23+
devDependencies: {
24+
'gulp-awspublish': '^3.0.1',
25+
'concurrent-transform': '^1.0.0'
26+
}
2727
});
2828
});
2929

3030
test('does not contain wrong uploading packages', () => {
31-
[
32-
'"gulp-rsync"',
33-
'"gulp-gh-pages"'
34-
].forEach(pack => {
35-
assert.noFileContent('package.json', pack);
31+
assert.noJSONFileContent('package.json', {
32+
devDependencies: {
33+
'gulp-rsync': '^0.0.5',
34+
'gulp-gh-pages': '^0.5.2'
35+
}
3636
});
3737
});
3838

test/uploading/ghpages.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,20 @@ test('creates package.json file', () => {
1919
});
2020

2121
test('contain correct uploading packages', () => {
22-
assert.fileContent('package.json', '"gulp-gh-pages": "^0.5.2"');
22+
assert.JSONFileContent('package.json', { // eslint-disable-line
23+
devDependencies: {
24+
'gulp-gh-pages': '^0.5.2'
25+
}
26+
});
2327
});
2428

2529
test('does not contain wrong uploading packages', () => {
26-
[
27-
'"gulp-awspublish"',
28-
'"concurrent-transform"',
29-
'"gulp-rsync"'
30-
].forEach(pack => {
31-
assert.noFileContent('package.json', pack);
30+
assert.noJSONFileContent('package.json', {
31+
devDependencies: {
32+
'gulp-awspublish': '^3.0.1',
33+
'concurrent-transform': '^1.0.0',
34+
'gulp-rsync': '^0.0.5'
35+
}
3236
});
3337
});
3438

test/uploading/no-uploading.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ test('does not create credentials files', () => {
2626
});
2727

2828
test('does not contain uploading packages', () => {
29-
[
30-
'"gulp-awspublish"',
31-
'"concurrent-transform"',
32-
'"gulp-rsync"',
33-
'"gulp-gh-pages"'
34-
].forEach(pack => {
35-
assert.noFileContent('package.json', pack);
29+
assert.noJSONFileContent('package.json', {
30+
devDependencies: {
31+
'gulp-awspublish': '^3.0.1',
32+
'concurrent-transform': '^1.0.0',
33+
'gulp-rsync': '^0.0.5',
34+
'gulp-gh-pages': '^0.5.2'
35+
}
3636
});
3737
});
3838

test/uploading/rsync.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,20 @@ test('creates package.json file', () => {
1919
});
2020

2121
test('contain correct uploading packages', () => {
22-
assert.fileContent('package.json', '"gulp-rsync": "^0.0.5"');
22+
assert.JSONFileContent('package.json', {
23+
devDependencies: {
24+
'gulp-rsync': '^0.0.5'
25+
}
26+
});
2327
});
2428

2529
test('does not contain wrong uploading packages', () => {
26-
[
27-
'"gulp-awspublish"',
28-
'"concurrent-transform"',
29-
'"gulp-gh-pages"'
30-
].forEach(pack => {
31-
assert.noFileContent('package.json', pack);
30+
assert.noJSONFileContent('package.json', {
31+
devDependencies: {
32+
'gulp-awspublish': '^3.0.1',
33+
'concurrent-transform': '^1.0.0',
34+
'gulp-gh-pages': '^0.5.2'
35+
}
3236
});
3337
});
3438

0 commit comments

Comments
 (0)