forked from slively/ng-context-menu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
105 lines (91 loc) · 2.62 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
var gulp = require('gulp'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
jshint = require('gulp-jshint'),
rename = require('gulp-rename'),
connect = require('gulp-connect'),
protractor = require("gulp-protractor").protractor,
program = require('commander'),
stylish = require('jshint-stylish'),
debug = false,
WATCH_MODE = 'watch',
RUN_MODE = 'run';
var mode = RUN_MODE;
function list(val) {
return val.split(',');
}
program
.version('0.0.1')
.option('-t, --tests [glob]', 'Specify which tests to run')
.option('-b, --browsers <items>', 'Specify which browsers to run on', list)
.option('-r, --reporters <items>', 'Specify which reporters to use', list)
.parse(process.argv);
gulp.task('lint', function () {
gulp.src('src/**/*.js')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter(stylish));
});
gulp.task('js', function() {
var jsTask = gulp.src('src/**/*.js')
.pipe(concat('ng-context-menu.js'))
.pipe(gulp.dest('dist'));
if (!debug) {
jsTask.pipe(uglify());
}
jsTask
.pipe(rename('ng-context-menu.min.js'))
.pipe(gulp.dest('dist'))
.pipe(connect.reload());
});
gulp.task('connect', function() {
if (mode === WATCH_MODE) {
gulp.watch(['index.html'], function() {
gulp.src(['index.html'])
.pipe(connect.reload());
});
}
connect.server({
livereload: mode === WATCH_MODE
});
});
gulp.task('protractor', function(done) {
gulp.src(["./src/tests/*.js"])
.pipe(protractor({
configFile: 'protractor.conf.js',
args: [
'--baseUrl', 'http://127.0.0.1:8080',
'--browser', program.browsers ? program.browsers[0] : 'phantomjs'
]
}))
.on('end', function() {
if (mode === RUN_MODE) {
connect.serverClose();
}
done();
})
.on('error', function() {
if (mode === RUN_MODE) {
connect.serverClose();
}
done();
});
});
gulp.task('debug', function() {
debug = true;
});
gulp.task('watch-mode', function() {
mode = WATCH_MODE;
});
function watch() {
var jsWatcher = gulp.watch('src/**/*.js', ['js', 'lint']);
function changeNotification(event) {
console.log('File', event.path, 'was', event.type, ', running tasks...');
}
jsWatcher.on('change', changeNotification);
}
// Removing protractor from default task until phantomjs issue is fixed
// https://github.com/ariya/phantomjs/issues/11429
//gulp.task('default', ['watch-mode', 'js', 'lint', 'protractor'], watch);
gulp.task('default', ['watch-mode', 'js', 'lint'], watch);
gulp.task('server', ['connect', 'default']);
gulp.task('test', ['connect', 'protractor']);