-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
74 lines (64 loc) · 1.99 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
'use strict';
const gulp = require('gulp');
const clean = require('gulp-clean');
const minify = require('gulp-minify');
const gls = require('gulp-live-server');
const protractor = require("gulp-protractor").protractor;
const PATH = {
components: './sample/app/components',
dist: './dist',
app: './sample/app/',
src: './src/qprotractor.js',
test: './test/*.spec.js',
protractorConfig: './protractor.config.js'
};
const APP_FILES_TO_WATCH = 'sample/app/**/*.*';
const APP_COMPONENTS = [
'./node_modules/angular/angular.min.js',
'./node_modules/angular-ui-router/release/angular-ui-router.min.js',
'./node_modules/angular-messages/angular-messages.min.js',
];
gulp.task('clean-dist', function() {
return gulp.src(PATH.dist, { read: false }).pipe(clean());
});
gulp.task('clean-app-components', function() {
return gulp.src(PATH.components, { read: false }).pipe(clean());
});
gulp.task('publish', ['clean-dist', 'copy-app-components'], function() {
gulp
.src(PATH.src)
.pipe(minify({
ext: {
min: '.min.js'
}
}))
.pipe(gulp.dest(PATH.dist));
});
gulp.task('serve', ['publish'], function() {
let server = gls.static(PATH.app, 9000);
server.start();
gulp.watch(APP_FILES_TO_WATCH, function(file) {
server.notify.apply(server, [file]);
});
});
let serverNoWatch;
gulp.task('serve-no-watch', ['publish'], function() {
serverNoWatch = gls.static(PATH.app, 9000);
serverNoWatch.start();
});
gulp.task('copy-app-components', ['clean-app-components'], function() {
gulp
.src(APP_COMPONENTS)
.pipe(gulp.dest(PATH.components));
});
gulp.task('protractor-test', ['serve-no-watch'], function() {
return gulp.src(PATH.test)
.pipe(protractor({
configFile: PATH.protractorConfig
}))
.on('close', function() {
console.log('exit');
serverNoWatch.stop();
})
.on('error', function(e) { throw e; });
});