forked from eduardolundgren/tracking.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
95 lines (83 loc) · 2.14 KB
/
gulpfile.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
'use strict';
var gulp = require('gulp');
var concat = require('gulp-concat');
var header = require('gulp-header');
var jshint = require('gulp-jshint');
var nodeunit = require('gulp-nodeunit');
var pkg = require('./package.json');
var rename = require('gulp-rename');
var rimraf = require('gulp-rimraf');
var stylish = require('jshint-stylish');
var uglify = require('gulp-uglify');
gulp.task('all', ['clean', 'build', 'build-data']);
gulp.task('clean', function() {
return gulp.src('build', {
read: false
})
.pipe(rimraf());
});
gulp.task('build', function() {
var files = [
'src/tracking.js',
'src/Brief.js',
'src/Canvas.js',
'src/EPnP.js',
'src/Fast.js',
'src/Math.js',
'src/Matrix.js',
'src/Tracker.js',
'src/ColorTracker.js',
'src/HumanTracker.js'
];
return gulp.src(files)
.pipe(concat('tracking.js'))
.pipe(banner())
.pipe(gulp.dest('build'))
.pipe(uglify())
.pipe(rename(function(filepath) {
filepath.basename += '-min';
}))
.pipe(banner())
.pipe(gulp.dest('build'));
});
gulp.task('build-data', function() {
return gulp.src('src/data/**.js')
.pipe(banner())
.pipe(gulp.dest('build/data'))
.pipe(rename(function(filepath) {
filepath.basename += '-min';
}))
.pipe(uglify())
.pipe(banner())
.pipe(gulp.dest('build/data'));
});
gulp.task('lint', function() {
return gulp.src('src/**.js')
.pipe(jshint())
.pipe(jshint.reporter(stylish));
});
gulp.task('test', function() {
return gulp.src('test/*.js').pipe(nodeunit());
});
gulp.task('test-watch', function() {
return gulp.watch(['src/*.js', 'test/**/*.js'], ['test']);
});
gulp.task('watch', function() {
gulp.watch('src/*.js', ['build']);
gulp.watch('src/data/*.js', ['build-data']);
});
// Private helpers
// ===============
function banner() {
var stamp = [
'/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @author <%= pkg.author.name %> <<%= pkg.author.email %>>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' */',
''
].join('\n');
return header(stamp, { pkg: pkg });
}