@@ -3,68 +3,51 @@ module.exports = function( grunt ) {
3
3
4
4
"use strict" ;
5
5
6
+ var files = [
7
+ "jquery.simulate.js" ,
8
+ "Gruntfile.js" ,
9
+ "test/*.js" ,
10
+ "test/unit/*.js"
11
+ ] ;
12
+
6
13
grunt . loadNpmTasks ( "grunt-update-submodules" ) ;
7
14
grunt . loadNpmTasks ( "grunt-compare-size" ) ;
8
15
grunt . loadNpmTasks ( "grunt-git-authors" ) ;
16
+ grunt . loadNpmTasks ( "grunt-contrib-qunit" ) ;
17
+ grunt . loadNpmTasks ( "grunt-contrib-uglify" ) ;
18
+ grunt . loadNpmTasks ( "grunt-contrib-jshint" ) ;
9
19
10
20
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" ) ,
16
22
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
21
28
} ,
22
29
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
-
46
30
qunit : {
47
31
files : "test/index.html"
48
32
} ,
49
33
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
+ }
57
42
} ,
58
43
59
44
compare_size : {
60
45
files : [ "dist/jquery.simulate.js" , "dist/jquery.simulate.min.js" ]
61
46
}
62
47
} ) ;
63
48
64
-
65
-
66
- grunt . registerHelper ( "git-date" , function ( fn ) {
67
- grunt . utils . spawn ( {
49
+ function git_date ( fn ) {
50
+ grunt . util . spawn ( {
68
51
cmd : "git" ,
69
52
args : [ "log" , "-1" , "--pretty=format:%ad" ]
70
53
} , function ( error , result ) {
@@ -75,7 +58,7 @@ grunt.registerHelper( "git-date", function( fn ) {
75
58
76
59
fn ( null , result ) ;
77
60
} ) ;
78
- } ) ;
61
+ }
79
62
80
63
grunt . registerTask ( "max" , function ( ) {
81
64
var dist = "dist/jquery.simulate.js" ,
@@ -86,7 +69,7 @@ grunt.registerTask( "max", function() {
86
69
version += " " + process . env . COMMIT ;
87
70
}
88
71
89
- grunt . helper ( "git-date" , function ( error , date ) {
72
+ git_date ( function ( error , date ) {
90
73
if ( error ) {
91
74
return done ( false ) ;
92
75
}
@@ -143,7 +126,7 @@ grunt.registerTask( "manifest", function() {
143
126
} , null , "\t" ) ) ;
144
127
} ) ;
145
128
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" ] ) ;
148
131
149
132
} ;
0 commit comments