1
1
/*global config:true, task:true*/
2
- config . init ( {
3
- pkg : '<json:package.json>' ,
4
- meta : {
5
- banner : '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
6
- '<%= template.today("m/d/yyyy") %>\n' +
7
- '<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' +
8
- '* Copyright (c) <%= template.today("yyyy") %> <%= pkg.author.name %>;' +
9
- ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
10
- } ,
11
- concat : {
12
- 'dist/jquery.validate.js' : [ '<banner>' , '<file_strip_banner:jquery.validate.js>' ] ,
13
- 'dist/additional-methods.js' : [ '<banner>' , '<file_strip_banner:additional-methods.js>' ]
14
- } ,
15
- min : {
16
- 'dist/jquery.validate.min.js' : [ '<banner>' , 'dist/jquery.validate.js' ] ,
17
- 'dist/additional-methods.min.js' : [ '<banner>' , 'dist/additional-methods.js' ]
18
- } ,
19
- zip : {
20
- dist : {
21
- src : [
22
- 'dist/additional-methods.js' ,
23
- 'dist/additional-methods.min.js' ,
24
- 'dist/jquery.validate.js' ,
25
- 'dist/jquery.validate.min.js' ,
26
- 'README.md' ,
27
- 'changelog.txt' ,
28
- 'grunt.js' ,
29
- 'package.json' ,
30
- 'demo/**/*' ,
31
- 'lib/**/*' ,
32
- 'localization/**/*' ,
33
- 'test/**/*'
34
- ] ,
35
- dest : 'dist/<%= pkg.name %>-<%= pkg.version %>.zip'
36
- }
37
- } ,
38
- qunit : {
39
- files : [ 'test/index.html' ]
40
- } ,
41
- lint : {
42
- files : [ 'jquery.validate.js' ]
43
- } ,
44
- jshint : {
45
- options : {
46
- curly : true ,
47
- eqeqeq : true ,
48
- immed : true ,
49
- latedef : true ,
50
- newcap : true ,
51
- noarg : true ,
52
- sub : true ,
53
- undef : true ,
54
- eqnull : true ,
55
- browser : true
56
- } ,
57
- globals : {
58
- jQuery : true ,
59
- $ : true ,
60
- console : true
61
- }
62
- }
2
+ module . exports = function ( grunt ) {
3
+
4
+ grunt . initConfig ( {
5
+ pkg : '<json:package.json>' ,
6
+ meta : {
7
+ banner : '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
8
+ '<%= grunt.template.today("m/d/yyyy") %>\n' +
9
+ '<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' +
10
+ '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
11
+ ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
12
+ } ,
13
+ concat : {
14
+ 'dist/jquery.validate.js' : [ '<banner>' , '<file_strip_banner:jquery.validate.js>' ] ,
15
+ 'dist/additional-methods.js' : [ '<banner>' , '<file_strip_banner:additional-methods.js>' ]
16
+ } ,
17
+ min : {
18
+ 'dist/jquery.validate.min.js' : [ '<banner>' , 'dist/jquery.validate.js' ] ,
19
+ 'dist/additional-methods.min.js' : [ '<banner>' , 'dist/additional-methods.js' ]
20
+ } ,
21
+ zip : {
22
+ dist : {
23
+ src : [
24
+ 'dist/additional-methods.js' ,
25
+ 'dist/additional-methods.min.js' ,
26
+ 'dist/jquery.validate.js' ,
27
+ 'dist/jquery.validate.min.js' ,
28
+ 'README.md' ,
29
+ 'changelog.txt' ,
30
+ 'grunt.js' ,
31
+ 'package.json' ,
32
+ 'demo/**/*.*' ,
33
+ 'lib/**/*.*' ,
34
+ 'localization/**/*.*' ,
35
+ 'test/**/*.*'
36
+ ] ,
37
+ dest : 'dist/<%= pkg.name %>-<%= pkg.version %>.zip'
38
+ }
39
+ } ,
40
+ qunit : {
41
+ files : [ 'test/index.html' ]
42
+ } ,
43
+ lint : {
44
+ files : [ 'jquery.validate.js' ]
45
+ } ,
46
+ jshint : {
47
+ options : {
48
+ curly : true ,
49
+ eqeqeq : true ,
50
+ immed : true ,
51
+ latedef : true ,
52
+ newcap : true ,
53
+ noarg : true ,
54
+ sub : true ,
55
+ undef : true ,
56
+ eqnull : true ,
57
+ browser : true
58
+ } ,
59
+ globals : {
60
+ jQuery : true ,
61
+ $ : true ,
62
+ console : true
63
+ }
64
+ }
63
65
} ) ;
64
66
65
- task . registerBasicTask ( 'zip' , 'Create a zip file for release' , function ( data ) {
66
- var files = file . expand ( data . src ) ;
67
- log . writeln ( "Creating zip file " + data . dest ) ;
67
+ grunt . registerMultiTask ( 'zip' , 'Create a zip file for release' , function ( ) {
68
+ var files = grunt . file . expand ( this . file . src ) ;
69
+ // grunt.log.writeln(require('util').inspect(files));
70
+ grunt . log . writeln ( "Creating zip file " + this . file . dest ) ;
68
71
69
- var done = this . async ( ) ;
72
+ var done = this . async ( ) ;
70
73
71
- var zipstream = require ( 'zipstream' ) ;
72
- var fs = require ( 'fs' ) ;
74
+ var zipstream = require ( 'zipstream' ) ;
75
+ var fs = require ( 'fs' ) ;
73
76
74
- var out = fs . createWriteStream ( data . dest ) ;
75
- var zip = zipstream . createZip ( { level : 1 } ) ;
77
+ var out = fs . createWriteStream ( this . file . dest ) ;
78
+ var zip = zipstream . createZip ( { level : 1 } ) ;
76
79
77
- zip . pipe ( out ) ;
80
+ zip . pipe ( out ) ;
78
81
79
- function addFile ( ) {
80
- if ( ! files . length ) {
81
- zip . finalize ( function ( written ) {
82
- log . writeln ( written + ' total bytes written' ) ;
83
- done ( ) ;
84
- } ) ;
85
- return ;
86
- }
87
- var file = files . shift ( ) ;
88
- log . verbose . writeln ( 'Zipping ' + file ) ;
89
- zip . addFile ( fs . createReadStream ( file ) , { name : file } , addFile ) ;
90
- }
91
- addFile ( ) ;
82
+ function addFile ( ) {
83
+ if ( ! files . length ) {
84
+ zip . finalize ( function ( written ) {
85
+ grunt . log . writeln ( written + ' total bytes written' ) ;
86
+ done ( ) ;
87
+ } ) ;
88
+ return ;
89
+ }
90
+ var file = files . shift ( ) ;
91
+ grunt . log . verbose . writeln ( 'Zipping ' + file ) ;
92
+ zip . addFile ( fs . createReadStream ( file ) , { name : file } , addFile ) ;
93
+ }
94
+ addFile ( ) ;
92
95
} ) ;
93
96
94
- task . registerTask ( 'default' , 'lint qunit' ) ;
95
- task . registerTask ( 'release' , 'default concat min zip' ) ;
97
+ grunt . registerTask ( 'default' , 'lint qunit' ) ;
98
+ grunt . registerTask ( 'release' , 'default concat min zip' ) ;
99
+
100
+ } ;
0 commit comments