-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Gruntfile.js
95 lines (95 loc) · 2.7 KB
/
Gruntfile.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
module.exports = function(grunt) {
grunt.initConfig({
jshint: {
all: [ 'javascript/*.js' ]
},
uglify: {
javascript: {
expand: true,
cwd: 'javascript',
src: '*.js',
dest: 'minified'
}
}
});
grunt.task.registerTask('version', 'Check version consistency', function() {
var pkg = grunt.file.readJSON('package.json');
var JZZ = require('.');
var ver = JZZ().info().ver;
if (ver == pkg.version) {
grunt.log.ok('Version:', ver);
}
else {
grunt.log.error('Version:', ver, '!=', pkg.version);
return false;
}
var rdme = grunt.file.read('README.md').split(/\r?\n/);
for (var i = 0; i < rdme.length; i++) {
var match = rdme[i].match(/@(\d+\.\d+\.\d+)/);
if (match) {
ver = match[1];
if (ver == pkg.version) {
grunt.log.ok('README Version:', ver);
}
else {
grunt.log.error('README Version:', ver, '!=', pkg.version);
return false;
}
}
}
});
grunt.task.registerTask('ts', 'Check index.d.ts', function() {
var JZZ = require('.');
function F1() {}
JZZ.lib.copyMidiHelpers(F1);
var M1 = Object.keys(F1.prototype).sort();
var M1x = Object.keys(JZZ.MIDI.prototype).sort();
function F2() {}
JZZ.lib.copyUmpHelpers(F2);
var M2 = Object.keys(F2.prototype).sort();
var M2x = Object.keys(JZZ.UMP.prototype).sort();
var LIB = Object.keys(JZZ.lib).sort();
var ts = grunt.file.read('index.d.ts').split(/\r?\n/);
var list = {};
var current;
var i, k;
for (i = 0; i < ts.length; i++) {
var match = ts[i].match(/namespace\s+(\S+)/);
if (match) {
current = {};
list['namespace ' + match[1]] = current;
continue;
}
match = ts[i].match(/interface\s+(\S+)/);
if (match) {
if (match[1] == 'Constructor') continue;
current = {};
list['interface ' + match[1]] = current;
continue;
}
match = ts[i].match(/\s+(\S+)\(/);
if (match) {
current[match[1]] = true;
}
}
k = 'namespace MIDI';
for (i = 0; i < M1.length; i++) {
if (!list[k][M1[i]])
console.log('missing', k, ':', M1[i]);
}
k = 'interface MIDI';
for (i = 0; i < M1x.length; i++) {
if (M1x[i][0] == '_') continue;
if (!list[k][M1x[i]])
console.log('missing', k, ':', M1x[i]);
}
k = 'interface lib';
for (i = 0; i < LIB.length; i++) {
if (!list[k][LIB[i]])
console.log('missing', k, ':', LIB[i]);
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('default', ['jshint', 'uglify', 'version']);
};