forked from aengusmcmillin/AgreeMates
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
90 lines (74 loc) · 2.06 KB
/
Copy pathgulpfile.js
File metadata and controls
90 lines (74 loc) · 2.06 KB
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
// Register build and test automation tasks
'use strict';
// Include gulp
var gulp = require('gulp');
// Include plugins
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var istanbul = require('gulp-istanbul');
var mocha = require('gulp-mocha');
var bump = require('gulp-bump');
var karma = require('gulp-karma');
// Lint Task
gulp.task('lint', function() {
return gulp.src(['public/app/**/*.js', '!public/app/vendor/**/*.js',
'server/**/*.js'])
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
// Concatenate & Minify JS
gulp.task('scripts', function() {
return gulp.src('public/app/**/*.js')
.pipe(concat('all.js'))
.pipe(gulp.dest('build'))
.pipe(rename('all.min.js'))
.pipe(uglify())
.pipe(gulp.dest('build'));
});
// Watch Files For Changes
gulp.task('watch', function() {
gulp.watch(['**/*.js', '!node_modules/**/*.js', '!public/app/vendor/**/*.js'],
['lint', 'scripts']);
});
// Set up the file coverage
gulp.task('cover', function (cb) {
gulp.src(['server/**/*.js', '!server/test/**'])
.pipe(istanbul())
.on('end', cb);
});
// Testing
function handleError(err) {
console.log(err.toString());
this.emit('end');
}
function karmaTest(action) {
return gulp.src('./foobar')
.pipe(karma({
configFile: 'karma.conf.js',
action: action
}))
.on('error', handleError);
}
gulp.task('test', ['test:server', 'test:client'], function() {});
// Run server tests and output reports
gulp.task('test:server', function () {
gulp.src('./server/test/**/*.js')
.pipe(mocha({ reporter: 'list' }))
.on('error', handleError);
});
// Run client tests and output reports
gulp.task('test:client', function () {
return karmaTest('run');
});
gulp.task('test:client_watch', function () {
return karmaTest('watch');
});
gulp.task('bump', function () {
gulp.src(['./package.json', './bower.json'])
.pipe(bump())
.pipe(gulp.dest('./'));
});
// Default Task
gulp.task('default', ['lint', 'scripts', 'watch', 'test:client_watch']);