forked from katspaugh/wavesurfer.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
194 lines (186 loc) · 5.31 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*global module:false*/
module.exports = function(grunt) {
var path = require('path');
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
banner: '/*! <%= pkg.title || pkg.name %> <%= pkg.version %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* @license <%= pkg.license %> */',
// Task configuration.
concat: {
options: {
stripBanners: true
},
dist: {
src: [
'src/wavesurfer.js',
'src/util.js',
'src/webaudio.js',
'src/mediaelement.js',
'src/drawer.js',
'src/drawer.*.js'
],
dest: 'dist/wavesurfer.min.js'
}
},
connect: {
options: {
base: '.',
port: 9000,
// Change this to '0.0.0.0' to access the server from outside.
hostname: 'localhost',
keepalive: true
},
},
commonjs: {
modules: {
banner: '<%= banner %>',
cwd: 'dist',
src: ['*.min.js'],
dest: 'dist/wavesurfer.cjs.js'
}
},
amd: {
modules: {
banner: '<%= banner %>',
cwd: 'dist',
src: ['*.min.js'],
dest: 'dist/wavesurfer.amd.js'
}
},
uglify: {
options: {
banner: '<%= banner %>'
},
dist: {
options: {
sourceMap: 'dist/wavesurfer.min.js.map',
sourceMapRoot: '/'
},
src: '<%= concat.dist.src %>',
dest: '<%= concat.dist.dest %>'
},
plugins: {
files: grunt.file.expandMapping(['plugin/*.js'], 'dist/', {
rename: function(destBase, destPath) {
var newPath = destBase + destPath.replace('.js', '.min.js');
return newPath;
},
})
}
},
jshint: {
options: {
curly: true,
eqeqeq: false,
eqnull: true,
quotmark: "single",
browser: true,
// Missing "use strict" statement.
strict: false,
globals: {
WaveSurfer: true
},
},
ignore_warning: {
options: {
'-W004': true,
// Expected an assignment or function call and instead saw an expression
'-W030': true,
// {a} used out of scope
'-W038': true,
// Use '!==' to compare with ''
'-W041': true,
'-W056': true,
// Missing '()' invoking a constructor.
'-W058': true,
'-W079': true,
// Use the function form of 'use strict'
'-W097': true,
},
src: ['<%= concat.dist.src %>', 'plugin/*.js', 'spec/*.spec.js']
},
},
jasmine: {
core: {
src: '<%= concat.dist.src %>',
options: {
specs: ['spec/*.spec.js'],
vendor: [
'node_modules/jasmine-expect/dist/jasmine-matchers.js'
]
}
},
coverage: {
src: '<%= concat.dist.src %>',
options: {
specs: '<%= jasmine.core.options.specs %>',
vendor: '<%= jasmine.core.options.vendor %>',
template: require('grunt-template-jasmine-istanbul'),
templateOptions: {
coverage: 'coverage/coverage.json',
report: [
{
type: 'lcov',
options: {
dir: 'coverage/lcov'
}
},
{
type: 'html',
options: {
dir: 'coverage/html'
}
}]
}
}
}
},
coveralls: {
options: {
force: true
},
main_target: {
src: 'coverage/lcov/lcov.info'
}
}
});
// ==========================================================================
// TASKS
// ==========================================================================
grunt.registerMultiTask('commonjs', 'Wrap .js files for commonjs.', function () {
this.files.forEach(function(file) {
return file.src.map(function(filepath) {
var original = grunt.file.read(path.join(file.cwd, filepath));
return grunt.file.write(file.dest, file.banner + '\n' +
original + '\nmodule.exports = WaveSurfer;');
});
});
});
grunt.registerMultiTask('amd', 'Wrap .js files for AMD.', function () {
this.files.forEach(function(file) {
return file.src.map(function(filepath) {
var definePath = (filepath.replace(/\.\w+$/, '')),
original = grunt.file.read(path.join(file.cwd, filepath));
return grunt.file.write(file.dest, file.banner +
'\ndefine(function () {\n' + original + '\nreturn WaveSurfer;\n});');
});
});
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-coveralls');
grunt.loadNpmTasks('grunt-contrib-connect');
// Default task.
grunt.registerTask('default', ['jshint', 'test', 'coverage', 'concat', 'commonjs',
'amd', 'uglify']);
// Dev
grunt.registerTask('dev', ['concat', 'uglify', 'connect']);
grunt.registerTask('test', ['jasmine:core']);
grunt.registerTask('coverage', ['jasmine:coverage']);
};