-
Notifications
You must be signed in to change notification settings - Fork 12
/
Jakefile
110 lines (96 loc) · 2.05 KB
/
Jakefile
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
'use strict';
var findFiles = function(files, extensions, callback) {
var find = require('find');
var finished = 0,
dirs = ['lib', 'test'];
for (var i = 0; i < extensions.length; i++) {
extensions[i] = '\\.' + extensions[i];
}
var exp = new RegExp('(?:' + extensions.join('|') + ')$');
var found = function() {
finished++;
if (dirs.length === finished) {
callback(files);
}
};
dirs.forEach(function(dir) {
find.file(exp, dir, function(f) {
files = files.concat(f);
found();
});
});
};
desc('Installs all dependencies');
task('setup', {
async: true
}, function() {
jake.exec('npm install', {
printStdout: true,
printStderr: true
}, function() {
complete();
});
});
desc('Runs jshint');
task('jshint', {
async: true
}, function() {
jake.exec('./node_modules/.bin/jshint . Jakefile', {
printStdout: true,
printStderr: true
}, function() {
complete();
});
});
desc('Alias of jshint');
task('lint', ['jshint']);
desc('Runs mocha');
task('mocha', {
async: true
}, function() {
var cmds = [
'./node_modules/.bin/mocha'
];
jake.exec(cmds, {
printStdout: true,
printStderr: true
}, function() {
complete();
});
});
desc('Runs the test suite');
task('test', ['jshint', 'mocha']);
desc('Runs js-beautify');
task('beautify', {
async: true
}, function() {
findFiles(['Jakefile', 'package.json', '.jshintrc', '.jsbeautifyrc'], ['js', 'json'], function(files) {
jake.exec('./node_modules/.bin/js-beautify ' + files.join(' '), {
printStdout: true,
printStderr: true
}, function() {
complete();
});
});
});
desc('Clean dev dependencies');
task('clean', function() {
var rimraf = require('rimraf');
[
'package-lock.json',
'node_modules'
].forEach(function(path) {
rimraf(path, function(err) {
if (err) {
console.error(err);
}
});
});
});
// task shortcuts
task('b', ['beautify']);
task('t', ['test']);
task('m', ['mocha']);
task('j', ['jshint']);
task('s', ['setup']);
task('c', ['clean']);