forked from leapmotion/leapjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
111 lines (107 loc) · 3.07 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
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 BSD-2-Clause license \
\n * http://github.com/leapmotion/leapjs/blob/master/LICENSE.txt \
\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/*',
'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] %>"
},
// bower.json
{
pattern: /"version": "\d.\d.\d"/,
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']
}
},
watch: {
files: 'lib/*',
tasks: ['default']
},
exec: {
'test-browser': './node_modules/.bin/mocha-phantomjs -R dot test/helpers/browser.html',
'test-node': './node_modules/.bin/mocha lib/index.js test/helpers/node.js test/*.js -R dot',
'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',
'exec:test-browser',
'exec:test-node',
'exec:test-integration'
]);
}