-
Notifications
You must be signed in to change notification settings - Fork 19
/
gulpfile.js
executable file
·105 lines (90 loc) · 2.19 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
'use strict';
var gulp = require('gulp'),
selenium = require('selenium-standalone'),
runSequence = require('run-sequence'),
$ = require('gulp-load-plugins')();
// because gulp-load-$ loads plugins only with prefix gulp-. Shit.
$.browserSync = require('browser-sync');
var config = {
/* uncomment below if you not need php */
server: {
baseDir: './'
},
startPath: 'examples/basic',
//tunnel: true,
host: 'localhost',
//port: 9000,
logPrefix: 'Frontend'
};
var notifyConfig = {
title: '<%= error.plugin %>',
message: '<%= error.message %> in file <%= error.fileName %>:<%= error.lineNumber %>'
};
gulp.task('jcarouselSwipe:build', function () {
gulp.src('src/*.js')
.pipe($.plumber({
errorHandler: $.notify.onError(notifyConfig)
}))
.pipe(gulp.dest('dist/'))
.pipe($.uglify())
.pipe($.rename({
extname: '.min.js'
}))
.pipe(gulp.dest('dist/'))
.pipe($.browserSync.reload({stream: true}));
});
gulp.task('build', [
'jcarouselSwipe:build'
]);
gulp.task('watch', function () {
$.watch(['src/*.js'], function (event, cb) {
gulp.start('jcarouselSwipe:build');
});
$.watch(['examples/**/*.*'], function() {
$.browserSync.reload();
});
});
gulp.task('webserver', function () {
$.browserSync(config);
});
gulp.task('clean', function (cb) {
rimraf('dist/', cb);
});
gulp.task('runtests:selenium', function (done) {
selenium.install(
{
logger: function (message) {
console.log(message);
}
},
function (error) {
if (error) return done(error);
selenium.start(function (error, child) {
if (error) return done(error);
selenium.child = child;
done();
});
}
);
});
gulp.task('runtests:codeceptjs', function(done) {
$.run('node_modules/codeceptjs/bin/codecept.js run --debug').exec(function() {
done();
});
});
gulp.task('runtests:webserver', function(done) {
$.browserSync({
server: config.server,
host: config.host,
open: false
}, function() {
done();
});
});
gulp.task('runtests', function() {
runSequence('runtests:selenium', ['runtests:webserver', 'runtests:codeceptjs'], function() {
selenium.child.kill();
$.browserSync.exit();
});
});
gulp.task('default', ['build', 'webserver', 'watch']);