-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jakefile.js
74 lines (55 loc) · 2.24 KB
/
Jakefile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
var build = require('./build/build.js'),
lint = require('./build/hint.js'),
vers = require('./build/version.js');
var BOILERPLATE =
'/* ==========================================================\n' +
'* leafpile.js v'+VERSION+'\n' +
'* A marker clustering layer for Leaflet maps\n' +
'* http://github.com/cavis/leafpile\n' +
'* ==========================================================\n' +
'* Copyright (c) 2012 Ryan Cavis\n' +
'* Licensed under http://en.wikipedia.org/wiki/MIT_License\n' +
'* ========================================================== */\n';
desc('Check Leafpile 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');
}
});
desc('Combine and compress Leafpile source files');
task('build', ['lint'], function (compsBase32, buildName) {
var files = build.getFiles(compsBase32);
console.log('Concatenating ' + files.length + ' files...');
var content = build.combineFiles(files),
newSrc = BOILERPLATE + content,
pathPart = 'dist/leafpile' + (buildName ? '-' + buildName : ''),
srcPath = pathPart + '-src.js',
oldSrc = build.load(srcPath),
srcDelta = build.getSizeDelta(newSrc, oldSrc);
console.log('\tUncompressed size: ' + newSrc.length + ' bytes (' + srcDelta + ')');
if (newSrc === oldSrc) {
console.log('\tNo changes');
} else {
build.save(srcPath, newSrc);
console.log('\tSaved to ' + srcPath);
}
console.log('Compressing...');
var path = pathPart + '.js',
oldCompressed = build.load(path),
newCompressed = BOILERPLATE + build.uglify(content),
delta = build.getSizeDelta(newCompressed, oldCompressed);
console.log('\tCompressed size: ' + newCompressed.length + ' bytes (' + delta + ')');
if (newCompressed === oldCompressed) {
console.log('\tNo changes');
} else {
build.save(path, newCompressed);
console.log('\tSaved to ' + path);
}
});
task('default', ['build']);