-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGulpfile.js
86 lines (76 loc) · 2.32 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
'use strict';
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var jscs = require('gulp-jscs');
var stylish = require('gulp-jscs-stylish');
var concat = require('gulp-concat');
var nodemon = require('gulp-nodemon');
var ngAnnotate = require('gulp-ng-annotate');
var protractor = require('gulp-protractor').protractor;
var webdriverStandalone = require('gulp-protractor').webdriver_standalone;
var webdriverUpdate = require('gulp-protractor').webdriver_update;
var path = require('path');
var karma = require('karma');
gulp.task('build-js', ['codestyle'], function () {
return gulp.src('client/**/!(*.spec).js')
.pipe(ngAnnotate())
.pipe(concat('app.js'))
.pipe(gulp.dest('dist/'))
;
});
gulp.task('build-lib', function () {
return gulp.src([
'node_modules/angular/angular.js',
'node_modules/angular-ui-router/release/angular-ui-router.js'
])
.pipe(gulp.dest('dist/lib/'))
;
});
gulp.task('build-static', function () {
return gulp.src('client/**/!(*.js)')
.pipe(gulp.dest('dist/'))
;
});
gulp.task('build-app', ['build-js', 'build-static']);
gulp.task('build', ['build-lib', 'build-app']);
gulp.task('default', ['codestyle', 'build', 'start']);
gulp.task('start', ['build'], function() {
gulp.watch('client/**/*', ['codestyle', 'build-app']);
return nodemon({
script: 'index.js',
ext: 'js',
});
});
gulp.task('test', function() {
return gulp.src(['tests/**/*.js'], { read: false })
.pipe(protractor({
configFile: 'tests/protractor.config.js',
args: ['--baseUrl', 'http://localhost:9000'],
}))
;
});
gulp.task('unit', ['build'], function (done) {
var server = new karma.Server({
configFile: path.join(__dirname, '/karma.conf.js'),
singleRun: true,
autoWatch: false,
reporters: ['progress', 'coverage'],
preprocessors: {
'dist/**/*.html': ['ng-html2js'],
'dist/**/*.js': ['coverage'],
},
}, function(failCount) {
done(failCount ? new Error('Failed ' + failCount + ' tests.') : null);
});
server.start();
});
gulp.task('webdriverUpdate', webdriverUpdate);
gulp.task('webdriverStandalone', webdriverStandalone);
gulp.task('codestyle', function() {
return gulp.src(['client/**/*.js'])
.pipe(jshint())
.pipe(jscs())
.pipe(stylish.combineWithHintResults())
.pipe(jshint.reporter('jshint-stylish'))
;
});