2011-12-13 01:54:03 +08:00
|
|
|
var build = require('./build/build.js'),
|
|
|
|
lint = require('./build/hint.js');
|
2011-12-12 08:32:53 +08:00
|
|
|
|
2011-12-13 04:21:20 +08:00
|
|
|
var crlf = '\r\n',
|
|
|
|
COPYRIGHT = '/*' + crlf + ' Copyright (c) 2010-2011, CloudMade, Vladimir Agafonkin' + crlf +
|
|
|
|
' Leaflet is a modern open-source JavaScript library for interactive maps.' + crlf +
|
|
|
|
' http://leaflet.cloudmade.com' + crlf + '*/' + crlf;
|
2011-12-12 08:32:53 +08:00
|
|
|
|
2011-12-13 03:48:20 +08:00
|
|
|
desc('Check Leaflet source for errors with JSHint');
|
2011-12-13 01:54:03 +08:00
|
|
|
task('lint', function () {
|
|
|
|
var files = build.getFiles();
|
|
|
|
|
|
|
|
console.log('Checking for JS errors...');
|
|
|
|
|
|
|
|
var errorsFound = lint.jshint(files);
|
|
|
|
|
|
|
|
if (errorsFound > 0) {
|
|
|
|
console.log(errorsFound + ' error(s) found.\n');
|
|
|
|
fail();
|
|
|
|
} else {
|
|
|
|
console.log('\tCheck passed');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2011-12-13 03:48:20 +08:00
|
|
|
desc('Combine and compress Leaflet source files');
|
2011-12-13 01:54:03 +08:00
|
|
|
task('build', ['lint'], function (compsBase32, buildName) {
|
2011-12-12 17:42:42 +08:00
|
|
|
var name = buildName || 'custom',
|
2011-12-13 01:54:03 +08:00
|
|
|
path = 'dist/leaflet' + (compsBase32 ? '-' + name : '');
|
2011-12-12 08:32:53 +08:00
|
|
|
|
2011-12-12 18:44:16 +08:00
|
|
|
var files = build.getFiles(compsBase32);
|
2011-12-12 08:32:53 +08:00
|
|
|
|
|
|
|
console.log('Concatenating ' + files.length + ' files...');
|
2011-12-12 18:44:16 +08:00
|
|
|
var content = build.combineFiles(files);
|
2011-12-13 01:54:03 +08:00
|
|
|
console.log('\tUncompressed size: ' + content.length);
|
|
|
|
|
|
|
|
build.save(path + '-src.js', COPYRIGHT + content);
|
|
|
|
console.log('\tSaved to ' + path);
|
|
|
|
|
2011-12-12 04:45:49 +08:00
|
|
|
console.log('Compressing...');
|
2011-12-12 18:44:16 +08:00
|
|
|
var compressed = COPYRIGHT + build.uglify(content);
|
2011-12-13 01:54:03 +08:00
|
|
|
console.log('\tCompressed size: ' + compressed.length);
|
2011-12-12 08:32:53 +08:00
|
|
|
|
2011-12-13 01:54:03 +08:00
|
|
|
build.save(path + '.js', compressed);
|
|
|
|
console.log('\tSaved to ' + path);
|
2011-12-12 04:45:49 +08:00
|
|
|
});
|
|
|
|
|
2011-12-13 01:54:03 +08:00
|
|
|
task('default', ['build']);
|