forked from shoshi/angular-breadcrumbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
111 lines (91 loc) · 2.83 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
var path = require('path'),
gulp = require('gulp'),
uglify = require('gulp-uglify'),
connect = require('gulp-connect'),
karma = require('gulp-karma'),
jshint = require('gulp-jshint'),
webdriverUpdate = require("gulp-protractor").webdriver_update,
protractor = require("gulp-protractor").protractor,
concat = require('gulp-concat'),
rename = require('gulp-rename'),
debug = false,
WATCH_MODE = 'watch',
RUN_MODE = 'run';
var mode = WATCH_MODE;
function changeNotification(event) {
console.log('File', event.path, 'was', event.type, ', running tasks...');
}
gulp.task('uglify-js', function() {
gulp.src('src/**/*.js')
.pipe(concat('ng-breadcrumbs.js'))
.pipe(gulp.dest('dist'))
.pipe(uglify())
.pipe(rename('ng-breadcrumbs.min.js'))
.pipe(gulp.dest('dist'))
.pipe(connect.reload());
});
gulp.task('copy-js', function() {
gulp.src('src/**/*.js')
.pipe(concat('ng-breadcrumbs.js'))
.pipe(gulp.dest('dist'))
.pipe(rename('ng-breadcrumbs.min.js'))
.pipe(gulp.dest('dist'))
.pipe(connect.reload());
});
gulp.task('lint', function () {
gulp.src('src/js/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('karma', function() {
// undefined.js: unfortunately necessary for now
gulp.src(['undefined.js'])
.pipe(karma({
configFile: 'karma.conf.js',
action: mode
}))
.on('error', function() {});
});
gulp.task('protractor', ['webdriver-update'], function(callback) {
gulp.src(["./src/tests/*.js"])
.pipe(protractor({
configFile: 'protractor.conf.js',
args: ['--baseUrl', 'http://127.0.0.1:8080']
}))
.on('end', function() {
callback();
})
.on('error', function(err) {
callback(err);
});
});
gulp.task('webdriver-update', webdriverUpdate);
function build() {
var jsTask = debug ? 'copy-js' : 'uglify-js';
var jsWatcher = gulp.watch('src/js/**/*.js', [jsTask, 'karma', 'protractor']),
testWatcher = gulp.watch('test/**/*.js', ['karma', 'protractor']);
jsWatcher.on('change', changeNotification);
testWatcher.on('change', changeNotification);
}
gulp.task('default', ['uglify-js', 'lint', 'karma', 'protractor'], build);
gulp.task('debug', ['debug-mode', 'copy-js', 'lint', 'karma', 'protractor'], build);
gulp.task('connect', function() {
gulp.watch(['public/**/*', 'index.html'], function() {
gulp.src(['public/**/*', 'index.html'])
.pipe(connect.reload());
});
connect.server({
livereload: true
});
});
gulp.task('server', ['connect', 'default']);
gulp.task('kill-connect', ['protractor'], function() {
connect.serverClose();
});
gulp.task('run-mode', function() {
mode = RUN_MODE;
});
gulp.task('debug-mode', function() {
debug = true;
});
gulp.task('test', ['run-mode', 'connect', 'uglify-js', 'karma', 'protractor', 'kill-connect']);