-
Notifications
You must be signed in to change notification settings - Fork 2
/
Gulpfile-test.js
53 lines (43 loc) · 1.43 KB
/
Gulpfile-test.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
var gulp = require('gulp'),
karma = require('gulp-karma'),
refresh = require('gulp-livereload'),
server = require('tiny-lr')(),
connect = require('connect'),
rewrite = require('connect-modrewrite'),
http = require('http'),
path = require('path');
gulp.task('server', function () {
var port = 3000,
hostname = null,
base = path.resolve('src'),
directory = path.resolve('src');
var routes = [
'^/[^\.]*$ /index.html'
];
var app = connect()
.use(rewrite(routes))
.use(connect.static(base, { hidden: true }))
.use(connect.directory(directory));
http.createServer(app).listen(port, hostname);
});
gulp.task('livereload', function() {
server.listen(35729, function (error) {
console.log(error || 'Livereload server started');
});
});
gulp.task('test', function () {
var files = [
'src/vendor/angular/angular.js',
'src/vendor/angular-mocks/angular-mocks.js',
'src/app/**/*.js'
];
return gulp.src(files).pipe(karma({ configFile: 'karma.conf.js', action: 'watch' }));
});
gulp.task('build', function () {
gulp.src('src')
.pipe(refresh(server));
});
gulp.task('watch', function () {
gulp.watch(['src/*.html', 'src/**/*.js'], ['build']);
});
gulp.task('default', ['livereload', 'server', 'watch', 'test']);