Skip to content

Commit bab8e84

Browse files
committed
Rewrite zip task to basic task, extracting the file list and zip file name.
1 parent 9feeed5 commit bab8e84

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

grunt.js

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,25 @@ config.init({
1616
'dist/jquery.validate.min.js': ['<banner>', 'dist/jquery.validate.js'],
1717
'dist/additional-methods.min.js': ['<banner>', 'dist/additional-methods.js']
1818
},
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+
},
1938
qunit: {
2039
files: ['test/index.html']
2140
},
@@ -43,17 +62,16 @@ config.init({
4362
}
4463
});
4564

46-
task.registerTask('zip', 'Create a zip file for release', function() {
47-
var folder = config('pkg').name + '-' + config('pkg').version;
48-
var target = 'dist/' + folder + '.zip';
49-
log.writeln('Zipping into ' + target);
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);
5068

5169
var done = this.async();
5270

5371
var zipstream = require('zipstream');
5472
var fs = require('fs');
5573

56-
var out = fs.createWriteStream(target);
74+
var out = fs.createWriteStream(data.dest);
5775
var zip = zipstream.createZip({ level: 1 });
5876

5977
zip.pipe(out);
@@ -67,29 +85,9 @@ task.registerTask('zip', 'Create a zip file for release', function() {
6785
return;
6886
}
6987
var file = files.shift();
70-
log.writeln('Zipping ' + file.file);
71-
zip.addFile(fs.createReadStream(file.file), { name: folder + '/' + file.name }, addFile);
88+
log.verbose.writeln('Zipping ' + file);
89+
zip.addFile(fs.createReadStream(file), { name: file }, addFile);
7290
}
73-
74-
// TODO use the concat results instead of copying the original source files
75-
// or don't use grunt's banner support, replace @VERSION instead
76-
var files = [{
77-
file: 'dist/additional-methods.min.js',
78-
name: 'additional-methods.min.js'
79-
},
80-
{
81-
file: 'dist/jquery.validate.min.js',
82-
name: 'jquery.validate.min.js'
83-
}];
84-
file.recurse('.', function(name) {
85-
if (/^(:?node_modules|dist|\.|build)/.test(name)) {
86-
return;
87-
}
88-
files.push({
89-
file: name,
90-
name: name
91-
});
92-
});
9391
addFile();
9492
});
9593

0 commit comments

Comments
 (0)