Skip to content
This repository was archived by the owner on Apr 24, 2019. It is now read-only.

Commit c9a12ad

Browse files
committed
Added Gruntfile.js to lint and test all the code
1 parent 63d7bc0 commit c9a12ad

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

Gruntfile.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* generator-init
3+
* https://github.com/use-init/generator-init
4+
*
5+
*/
6+
7+
'use strict';
8+
9+
module.exports = function (grunt) {
10+
11+
// Project configuration.
12+
grunt.initConfig({
13+
jshint: {
14+
all: [
15+
'Gruntfile.js',
16+
'app/index.js',
17+
'<%= mochaTest.test.src%>'
18+
],
19+
options: {
20+
jshintrc: '.jshintrc'
21+
}
22+
},
23+
24+
// Before generating any new files, remove any previously-created files.
25+
clean: {
26+
tests: ['tests/temp']
27+
},
28+
29+
// Unit tests.
30+
mochaTest: {
31+
test: {
32+
options: {
33+
reporter: 'spec'
34+
},
35+
src: ['test/*.js']
36+
}
37+
}
38+
39+
});
40+
41+
// These plugins provide necessary tasks.
42+
grunt.loadNpmTasks('grunt-contrib-jshint');
43+
grunt.loadNpmTasks('grunt-contrib-clean');
44+
grunt.loadNpmTasks('grunt-mocha-test');
45+
46+
// Whenever the "test" task is run, first clean the "temp" dir, then run this
47+
// plugin's task(s), then test the result.
48+
grunt.registerTask('test', ['clean', 'mochaTest']);
49+
50+
// By default, lint and run all tests.
51+
grunt.registerTask('default', ['clean', 'jshint', 'mochaTest']);
52+
53+
};

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ npm install -g yo
1111
npm install -g generator-init
1212
yo init
1313
```
14+
## Contributing
15+
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@
2525
"yeoman-generator": "~0.14.0"
2626
},
2727
"devDependencies": {
28-
"mocha": "~1.14.0"
28+
"mocha": "~1.14.0",
29+
"grunt": "~0.4.2",
30+
"grunt-mocha-test": "~0.8.1",
31+
"grunt-contrib-clean": "~0.5.0",
32+
"grunt-contrib-jshint": "~0.7.2"
2933
},
3034
"peerDependencies": {
3135
"yo": ">=1.0.0"

0 commit comments

Comments
 (0)