forked from nextcloud/contacts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
85 lines (71 loc) · 1.91 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
var gulp = require('gulp'),
concat = require('gulp-concat'),
eslint = require('gulp-eslint'),
stylelint = require('gulp-stylelint');
ngAnnotate = require('gulp-ng-annotate'),
merge = require('merge-stream'),
KarmaServer = require('karma').Server,
sourcemaps = require('gulp-sourcemaps');
var dependencies = require('./vendorScripts.json');
gulp.task('build', function() {
return gulp.src([
'js/main.js',
'js/components/**/*.js',
'js/models/**/*.js',
'js/services/**/*.js',
'js/filters/**/*.js'
])
// concat (+sourcemaps)
.pipe(sourcemaps.init())
.pipe(ngAnnotate({ single_quotes: true }))
.pipe(concat('script.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('js/public'));
});
gulp.task('vendor', function() {
let stream = require('merge-stream')();;
for(let dependency in dependencies.scripts) {
stream.add(
gulp.src(dependencies.scripts[dependency])
.pipe(gulp.dest(`js/vendor/${dependency}`))
);
}
for(let dependency in dependencies.styles) {
stream.add(
gulp.src(dependencies.styles[dependency])
.pipe(gulp.dest(`css/vendor/${dependency}`))
);
}
return stream;
});
gulp.task('eslint', function() {
return gulp.src([
'js/main.js',
'js/components/**/*.js',
'js/models/**/*.js',
'js/services/**/*.js',
'js/filters/**/*.js'
])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('stylelint', function() {
return gulp.src('css/*.scss')
.pipe(stylelint({
reporters: [
{formatter: 'string', console: true}
]
}));
});
gulp.task('karma', function(done){
new KarmaServer({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done).start();
});
gulp.task('default', ['vendor', 'eslint', 'stylelint', 'build']);
gulp.task('test', ['karma']);
gulp.task('watch', ['default'], function() {
gulp.watch(['js/**/*.js', '!js/public/**/*.js', 'css/*.scss'], ['eslint', 'stylelint', 'build']);
});