Skip to content

Commit

Permalink
Add release task to grunt.js, using custom zip task. Currently breaks…
Browse files Browse the repository at this point in the history
… due to a bug in zipstream (jquery-validation#5).
  • Loading branch information
jzaefferer committed Feb 29, 2012
1 parent aca2e93 commit 9feeed5
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -6,3 +6,4 @@ docs
*.diff
*.patch
.DS_Store
node_modules
Binary file removed demo/captcha/images/button.psd
Binary file not shown.
61 changes: 60 additions & 1 deletion grunt.js
Expand Up @@ -8,11 +8,19 @@ config.init({
'* Copyright (c) <%= template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
},
concat: {
'dist/jquery.validate.js': ['<banner>', '<file_strip_banner:jquery.validate.js>'],
'dist/additional-methods.js': ['<banner>', '<file_strip_banner:additional-methods.js>']
},
min: {
'dist/jquery.validate.min.js': ['<banner>', 'dist/jquery.validate.js'],
'dist/additional-methods.min.js': ['<banner>', 'dist/additional-methods.js']
},
qunit: {
files: ['test/index.html']
},
lint: {
files: ['grunt.js', 'jquery.validate.js']
files: ['jquery.validate.js']
},
jshint: {
options: {
Expand All @@ -35,4 +43,55 @@ config.init({
}
});

task.registerTask('zip', 'Create a zip file for release', function() {
var folder = config('pkg').name + '-' + config('pkg').version;
var target = 'dist/' + folder + '.zip';
log.writeln('Zipping into ' + target);

var done = this.async();

var zipstream = require('zipstream');
var fs = require('fs');

var out = fs.createWriteStream(target);
var zip = zipstream.createZip({ level: 1 });

zip.pipe(out);

function addFile() {
if (!files.length) {
zip.finalize(function(written) {
log.writeln(written + ' total bytes written');
done();
});
return;
}
var file = files.shift();
log.writeln('Zipping ' + file.file);
zip.addFile(fs.createReadStream(file.file), { name: folder + '/' + file.name }, addFile);
}

// TODO use the concat results instead of copying the original source files
// or don't use grunt's banner support, replace @VERSION instead
var files = [{
file: 'dist/additional-methods.min.js',
name: 'additional-methods.min.js'
},
{
file: 'dist/jquery.validate.min.js',
name: 'jquery.validate.min.js'
}];
file.recurse('.', function(name) {
if (/^(:?node_modules|dist|\.|build)/.test(name)) {
return;
}
files.push({
file: name,
name: name
});
});
addFile();
});

task.registerTask('default', 'lint qunit');
task.registerTask('release', 'default concat min zip');
2 changes: 1 addition & 1 deletion jquery.validate.js
Expand Up @@ -4,7 +4,7 @@
* http://bassistance.de/jquery-plugins/jquery-plugin-validation/
* http://docs.jquery.com/Plugins/Validation
*
* Copyright (c) 2006 - 2011 Jörn Zaefferer
* Copyright (c) 2012 Jörn Zaefferer
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
Expand Down
15 changes: 11 additions & 4 deletions package.json
@@ -1,8 +1,8 @@
{
"name": "validation",
"name": "jquery-validation",
"title": "jQuery Validation Plugin",
"description": "Form validation made easy",
"version": "1.9.0",
"version": "1.10.0pre",
"homepage": "https://github.com/jzaefferer/jquery-validation",
"author": {
"name": "Jörn Zaefferer",
Expand All @@ -19,10 +19,17 @@
"licenses": [
{
"type": "MIT",
"url": "https://github.com/jzaefferer/jquery-validation/blob/master/LICENSE-MIT"
"url": "http://www.opensource.org/licenses/MIT"
},
{
"type": "GPL",
"url": "http://www.opensource.org/licenses/GPL-2.0"
}
],
"dependencies": {},
"devDependencies": {},
"devDependencies": {
"grunt": "0.2.x",
"zipstream": "0.2.x"
},
"keywords": []
}

0 comments on commit 9feeed5

Please sign in to comment.