Skip to content

Commit 2d9759f

Browse files
committed
Updated Grunt and refactored Gruntfile.
Also changed .jshintrc predef to globals.
1 parent 25938de commit 2d9759f

File tree

3 files changed

+60
-69
lines changed

3 files changed

+60
-69
lines changed

grunt.js renamed to Gruntfile.js

Lines changed: 30 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,68 +3,51 @@ module.exports = function( grunt ) {
33

44
"use strict";
55

6+
var files = [
7+
"jquery.simulate.js",
8+
"Gruntfile.js",
9+
"test/*.js",
10+
"test/unit/*.js"
11+
];
12+
613
grunt.loadNpmTasks( "grunt-update-submodules" );
714
grunt.loadNpmTasks( "grunt-compare-size" );
815
grunt.loadNpmTasks( "grunt-git-authors" );
16+
grunt.loadNpmTasks( "grunt-contrib-qunit" );
17+
grunt.loadNpmTasks( "grunt-contrib-uglify" );
18+
grunt.loadNpmTasks( "grunt-contrib-jshint" );
919

1020
grunt.initConfig({
11-
pkg: "<json:package.json>",
12-
13-
meta: {
14-
banner: "/*! jQuery Simulate v@<%= pkg.version %> http://github.com/jquery/jquery-simulate | jquery.org/license */"
15-
},
21+
pkg: grunt.file.readJSON( "package.json" ),
1622

17-
lint: {
18-
src: [ "jquery.simulate.js" ],
19-
grunt: "grunt.js",
20-
test: [ "test/*.js", "test/unit/*.js" ]
23+
jshint: {
24+
options: {
25+
jshintrc: true
26+
},
27+
all: files
2128
},
2229

23-
jshint: (function() {
24-
function parserc( path ) {
25-
var rc = grunt.file.readJSON( (path || "") + ".jshintrc" ),
26-
settings = {
27-
options: rc,
28-
globals: rc.globals || {}
29-
};
30-
31-
(rc.predef || []).forEach(function( prop ) {
32-
settings.globals[ prop ] = true;
33-
});
34-
delete rc.predef;
35-
36-
return settings;
37-
}
38-
39-
return {
40-
src: parserc(),
41-
grunt: parserc(),
42-
test: parserc( "test/" )
43-
};
44-
})(),
45-
4630
qunit: {
4731
files: "test/index.html"
4832
},
4933

50-
min: {
51-
"dist/jquery.simulate.min.js": [ "<banner>", "dist/jquery.simulate.js" ]
52-
},
53-
54-
watch: {
55-
files: [ "<config:lint.src>", "<config:lint.test>", "<config:lint.grunt>" ],
56-
tasks: "default"
34+
uglify: {
35+
options: {
36+
banner: "/*! jQuery Simulate v@<%= pkg.version %> http://github.com/jquery/jquery-simulate | jquery.org/license */"
37+
},
38+
build: {
39+
src: "dist/jquery.simulate.js",
40+
dest: "dist/jquery.simulate.min.js"
41+
}
5742
},
5843

5944
compare_size: {
6045
files: [ "dist/jquery.simulate.js", "dist/jquery.simulate.min.js" ]
6146
}
6247
});
6348

64-
65-
66-
grunt.registerHelper( "git-date", function( fn ) {
67-
grunt.utils.spawn({
49+
function git_date( fn ) {
50+
grunt.util.spawn({
6851
cmd: "git",
6952
args: [ "log", "-1", "--pretty=format:%ad" ]
7053
}, function( error, result ) {
@@ -75,7 +58,7 @@ grunt.registerHelper( "git-date", function( fn ) {
7558

7659
fn( null, result );
7760
});
78-
});
61+
}
7962

8063
grunt.registerTask( "max", function() {
8164
var dist = "dist/jquery.simulate.js",
@@ -86,7 +69,7 @@ grunt.registerTask( "max", function() {
8669
version += " " + process.env.COMMIT;
8770
}
8871

89-
grunt.helper( "git-date", function( error, date ) {
72+
git_date(function( error, date ) {
9073
if ( error ) {
9174
return done( false );
9275
}
@@ -143,7 +126,7 @@ grunt.registerTask( "manifest", function() {
143126
}, null, "\t" ) );
144127
});
145128

146-
grunt.registerTask( "default", "lint update_submodules qunit build compare_size" );
147-
grunt.registerTask( "build", "max min" );
129+
grunt.registerTask( "default", ["jshint", "update_submodules", "qunit", "build", "compare_size"] );
130+
grunt.registerTask( "build", ["max", "uglify"] );
148131

149132
};

package.json

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,21 @@
2626
"url": "https://github.com/jquery/jquery-simulate/blob/master/MIT-LICENSE.txt"
2727
}
2828
],
29-
"dependencies": {},
3029
"devDependencies": {
31-
"grunt": "~0.3.17",
32-
"grunt-compare-size": "0.1.4",
33-
"grunt-git-authors": "1.0.0",
34-
"grunt-update-submodules": "0.1.2",
35-
"testswarm": "0.2.2"
30+
"grunt": "0.4.1",
31+
"grunt-contrib-qunit": "0.3.0",
32+
"grunt-contrib-uglify": "0.2.7",
33+
"grunt-compare-size": "0.4.0-rc.3",
34+
"grunt-git-authors": "1.2.0",
35+
"grunt-update-submodules": "0.2.0",
36+
"testswarm": "1.1.0",
37+
"grunt-contrib-jshint": "0.7.1"
3638
},
37-
"keywords": [ "simulate", "events", "keyboard", "mouse", "jquery" ]
38-
}
39+
"keywords": [
40+
"simulate",
41+
"events",
42+
"keyboard",
43+
"mouse",
44+
"jquery"
45+
]
46+
}

test/.jshintrc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313
"trailing": true,
1414
"undef": true,
1515
"unused": true,
16-
"predef": [
17-
"asyncTest",
18-
"deepEqual",
19-
"equal",
20-
"expect",
21-
"module",
22-
"notEqual",
23-
"ok",
24-
"QUnit",
25-
"start",
26-
"stop",
27-
"strictEqual",
28-
"test"
29-
]
16+
"globals": {
17+
"asyncTest": false,
18+
"deepEqual": false,
19+
"equal": false,
20+
"expect": false,
21+
"module": false,
22+
"notEqual": false,
23+
"ok": false,
24+
"QUnit": false,
25+
"start": false,
26+
"stop": false,
27+
"strictEqual": false,
28+
"test": false
29+
}
3030
}

0 commit comments

Comments
 (0)