1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | var path = require('path');
|
16 |
|
17 | desc('Check Leaflet.markercluster source for errors with JSHint');
|
18 | task('lint', function(){
|
19 | jake.exec('jshint', {
|
20 | printStdout: true
|
21 | }, function () {
|
22 | console.log('\tCheck passed.\n');
|
23 | complete();
|
24 | });
|
25 | });
|
26 |
|
27 | desc('Combine Leaflet.markercluster source files');
|
28 | task('build', ['lint'], function(){
|
29 | jake.exec('npm run-script rollup', function() { console.log('Rolled up.'); });
|
30 | });
|
31 |
|
32 | desc('Compress bundled files');
|
33 | task('uglify', ['build'], function(){
|
34 | jake.exec('npm run-script uglify', function() { console.log('Uglyfied.'); });
|
35 | });
|
36 |
|
37 | desc('Run PhantomJS tests');
|
38 | task('test', ['lint'], function() {
|
39 |
|
40 | var karma = require('karma'),
|
41 | testConfig = {configFile : path.join(__dirname, './spec/karma.conf.js')};
|
42 |
|
43 | testConfig.browsers = ['PhantomJS'];
|
44 |
|
45 | function isArgv(optName) {
|
46 | return process.argv.indexOf(optName) !== -1;
|
47 | }
|
48 |
|
49 | if (isArgv('--chrome')) {
|
50 | testConfig.browsers.push('Chrome');
|
51 | }
|
52 | if (isArgv('--safari')) {
|
53 | testConfig.browsers.push('Safari');
|
54 | }
|
55 | if (isArgv('--ff')) {
|
56 | testConfig.browsers.push('Firefox');
|
57 | }
|
58 | if (isArgv('--ie')) {
|
59 | testConfig.browsers.push('IE');
|
60 | }
|
61 |
|
62 | if (isArgv('--cov')) {
|
63 | testConfig.preprocessors = {
|
64 | 'src/**/*.js': 'coverage'
|
65 | };
|
66 | testConfig.coverageReporter = {
|
67 | type : 'html',
|
68 | dir : 'coverage/'
|
69 | };
|
70 | testConfig.reporters = ['coverage'];
|
71 | }
|
72 |
|
73 | console.log('Running tests...');
|
74 |
|
75 | var server = new karma.Server(testConfig, function(exitCode) {
|
76 | if (!exitCode) {
|
77 | console.log('\tTests ran successfully.\n');
|
78 | complete();
|
79 | } else {
|
80 | process.exit(exitCode);
|
81 | }
|
82 | });
|
83 | server.start();
|
84 | });
|
85 |
|
86 | task('default', ['build', 'uglify']);
|