Leaflet/Jakefile.js

46 lines
1.4 KiB
JavaScript
Raw Normal View History

var build = require('./build/build.js'),
lint = require('./build/hint.js');
2011-12-12 08:32:53 +08:00
2011-12-13 04:15:35 +08:00
var COPYRIGHT = "/*\r\n Copyright (c) 2010-2011, CloudMade, Vladimir Agafonkin\r\n" +
2011-12-13 03:48:20 +08:00
" Leaflet is a modern open-source JavaScript library for interactive maps.\n" +
2011-12-13 04:15:06 +08:00
" http://leaflet.cloudmade.com\r\n*/\r\n";
2011-12-12 08:32:53 +08:00
2011-12-13 03:48:20 +08:00
desc('Check Leaflet source for errors with JSHint');
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');
task('build', ['lint'], function (compsBase32, buildName) {
var name = buildName || 'custom',
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);
console.log('\tUncompressed size: ' + content.length);
build.save(path + '-src.js', COPYRIGHT + content);
console.log('\tSaved to ' + path);
console.log('Compressing...');
2011-12-12 18:44:16 +08:00
var compressed = COPYRIGHT + build.uglify(content);
console.log('\tCompressed size: ' + compressed.length);
2011-12-12 08:32:53 +08:00
build.save(path + '.js', compressed);
console.log('\tSaved to ' + path);
});
task('default', ['build']);