forked from leapmotion/leapjs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
126 lines (119 loc) · 3.42 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
module.exports = function(grunt){
var filename = "leap-<%= pkg.version %>";
var banner = "/*! \
\n * LeapJS v<%= pkg.version %> \
\n * http://github.com/leapmotion/leapjs/ \
\n * \
\n * Copyright 2013 LeapMotion, Inc. and other contributors \
\n * Released under the Apache-2.0 license \
\n * http://github.com/leapmotion/leapjs/blob/master/LICENSE \
\n */";
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
// This updates the version.js to match pkg.version
'string-replace': {
build: {
files: {
'lib/': 'lib/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: /leap.*\.js/,
replacement: filename + '.js'
}
]
}
}
},
clean: {
build: {
src: ['./leap-*.js']
}
},
browserify: {
build: {
options: {
ignore: ['lib/connection/node.js']
},
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: {
options: {
atBegin: true
},
files: 'lib/**/*',
tasks: ['default'],
test: {
files: ['lib/*', '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 lib/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'
]);
};