-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
45 lines (41 loc) · 1.22 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
'use strict';
const gulp = require('gulp'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
babel = require('gulp-babel'),
concat = require('gulp-concat'),
server = require('karma').Server,
wrap = require("gulp-wrap");
// Concatenate & Minify JS
gulp.task('scripts', function () {
return gulp.src('src/*.js')
.pipe(concat('typeahead.js'))
.pipe(wrap('(function ($) {<%= contents %>}(window.jQuery));'))
.pipe(babel({
presets: ['es2015']
}))
.pipe(gulp.dest('dist'))
.pipe(rename('typeahead.min.js'))
.pipe(uglify())
.pipe(gulp.dest('dist'));
});
gulp.task('test', ['scripts'], function (done) {
new server({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, function (exitCode) {
done();
process.exit(exitCode);
}).start();
});
// Watch for file changes and re-run tests on each change
gulp.task('tdd', function (done) {
new server({
configFile: __dirname + '/karma.conf.js'
}, function () {
done();
}).start();
return gulp.watch('src/*.js', ['scripts']);
});
gulp.task('deploy', ['scripts']);
gulp.task('default', ['scripts', 'test']);