forked from pelias/leaflet-plugin
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Jakefile.js
95 lines (75 loc) · 2.12 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
Task runner for testing and linting scripts.
Based off of Leaflet's own test suite.
To use, install Node, then install project dependencies from the project root:
npm install
To check the code & run tests:
npm test
*/
/* global jake, desc, task, complete */
var path = require('path');
function hint (msg, path) {
return function () {
var command = 'node node_modules/.bin/eslint ' + path;
var done = function () {
console.log('\tCheck passed.\n');
complete();
};
console.log(msg);
jake.exec(command, { printStdout: true }, done);
};
}
function test (complete, fail) {
var karma = require('karma');
var testConfig = {
configFile: path.join(__dirname, '/spec/karma.conf.js')
};
testConfig.browsers = ['PhantomJS'];
function isArgv (optName) {
return process.argv.indexOf(optName) !== -1;
}
if (isArgv('--chrome')) {
testConfig.browsers.push('Chrome');
}
if (isArgv('--safari')) {
testConfig.browsers.push('Safari');
}
if (isArgv('--ff')) {
testConfig.browsers.push('Firefox');
}
if (isArgv('--ie')) {
testConfig.browsers.push('IE');
}
if (isArgv('--cov')) {
testConfig.preprocessors = {
'src/**/*.js': 'coverage'
};
testConfig.coverageReporter = {
type: 'html',
dir: 'coverage/'
};
testConfig.reporters = ['coverage'];
}
var server = new karma.Server(testConfig, function (exitCode) {
if (!exitCode) {
console.log('\tTests ran successfully.\n');
complete();
} else {
process.exit(exitCode);
}
});
console.log('Running tests...');
server.start();
}
desc('Check plugin JavaScript for errors with Semistandard');
task('lint', { async: true }, hint('Checking for JS errors...', 'src/*.js'));
desc('Check specs & support JavaScript for errors with Semistandard');
task('lintspec', { async: true }, hint('Checking for specs & support JS errors...', 'spec/suites/*.js *.js'));
desc('Run PhantomJS tests');
task('test', { async: true }, function () {
test(complete);
});
task('default', ['lint', 'lintspec', 'test']);
jake.addListener('complete', function () {
process.exit();
});