-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
119 lines (112 loc) · 3.65 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
module.exports = function(grunt){
var filename = "myojs-<%= pkg.version %>";
var banner = "/*! \
\n * MyoJS v<%= pkg.version %>\
\n * https://github.com/logotype/myojs.git\
\n * \
\n * Copyright 2015 Victor Norgren\
\n * Released under the MIT license\
\n */";
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
// This updates the Version.js to match pkg.version
'string-replace': {
build: {
files: {
'src/': 'src/Version.js',
'./': 'bower.json',
'examples/': 'examples/*.html',
'test/': 'test/helpers/browser.html'
},
options:{
replacements: [
// Version.js
{
pattern: /(full:\s)'.*'/,
replacement: "$1'<%= pkg.version %>'"
},
{
pattern: /(major:\s)\d/,
replacement: "$1<%= pkg.version.split('.')[0] %>"
},
{
pattern: /(minor:\s)\d/,
replacement: "$1<%= pkg.version.split('.')[1] %>"
},
{
pattern: /(dot:\s)\d.*/,
replacement: "$1<%= pkg.version.split('.')[2][0] %>"
},
// bower.json
{
pattern: /"version": ".*"/,
replacement: '"version": "<%= pkg.version %>"'
},
// examples
{
pattern: /myo.*\.js/,
replacement: filename + '.js'
}
]
}
}
},
clean: {
build: {
src: ['./myo-*.js']
}
},
browserify: {
build: {
src: 'template/entry.js',
dest: filename + '.js'
}
},
uglify: {
build: {
src: filename + '.js',
dest: filename + '.min.js'
}
},
usebanner: {
build: {
options: {
banner: banner
},
src: [filename + '.js', filename + '.min.js']
}
},
// run with `grunt watch` or `grunt test watch`
watch: {
files: 'src/**/*',
tasks: ['default'],
test: {
files: ['src/*', 'test/*'],
tasks: ['test']
}
},
exec: {
'test-browser': './node_modules/.bin/mocha-phantomjs -R dot test/helpers/browser.html',
// -i -g stands for inverse grep. Tests tagged browser-only will be excluded.
'test-node': './node_modules/.bin/mocha src/index.js test/helpers/node.js test/*.js -R dot -i -g browser-only',
'test-integration': 'node integration_test/reconnection.js && node integration_test/protocol_versions.js'
}
});
require('load-grunt-tasks')(grunt);
grunt.registerTask('default', [
'string-replace',
'clean',
'browserify',
'uglify',
'usebanner'
]);
grunt.registerTask('test', [
'default',
'test-only'
]);
grunt.registerTask('test-only', [
'exec:test-node',
'exec:test-browser',
'exec:test-integration'
]);
};