forked from doshprompt/angular-localization
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
110 lines (96 loc) · 3.01 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
106
107
108
109
110
var gulp = require('gulp'),
del = require('del'),
header = require('gulp-header'),
concat = require('gulp-concat'),
uglify = require('gulp-uglifyjs'),
using = require('gulp-using')
date = require('moment'),
gzip = require('gulp-gzip'),
karma = require('karma').server,
webserver = require('gulp-webserver'),
protractor = require('gulp-protractor').protractor,
webdriver_update = require('gulp-protractor').webdriver_update,
exit = require('gulp-exit'),
preprocess = require('gulp-preprocess'),
runSequence = require('run-sequence');
var paths = {
baseDir: 'src',
distDir: 'dist',
tempDir: 'tmp',
e2e: 'tests/e2e/*.js'
};
var pkg = require('./package.json');
pkg.todayDate = date().format('YYYY-MM-DD')
pkg.todayYear = date().format('YYYY')
var banner = [
'/**',
' * <%= pkg.title || pkg.name %> :: v<%= pkg.version %> :: <%= pkg.todayDate %>',
' * web: <%= pkg.homepage %>',
' *',
' * Copyright (c) <%= pkg.todayYear %> | <%= pkg.author %>',
' * License: <%= pkg.license %>',
' */',
''
].join('\n');
gulp.task('clean', function (cb) {
del([paths.distDir, paths.tempDir], cb);
});
gulp.task('concat', function () {
return gulp.src([
'build/module.prefix',
paths.baseDir + '/localization*.js',
'build/module.suffix'
])
.pipe(concat('angular-localization.js'))
.pipe(header(banner, { pkg : pkg } ))
.pipe(gulp.dest(paths.distDir))
});
gulp.task('uglify', function () {
return gulp.src(paths.distDir + '/angular-localization.js')
.pipe(uglify('angular-localization.min.js', {
outSourceMap: 'angular-localization.min.map',
basePath: 'dist/',
output: {
comments: /Copyright/
}
}))
.pipe(gulp.dest(paths.distDir))
});
gulp.task('compress', function () {
return gulp.src(paths.distDir + '/*.min.js')
.pipe(gzip())
.pipe(gulp.dest(paths.distDir))
});
gulp.task('karma', function (cb) {
karma.start({
configFile: __dirname + '/build/karma.conf.js'
}, cb);
});
// use this helper task to update webdriver to the latest version
gulp.task('webdriver-update', webdriver_update);
gulp.task('connect', function () {
gulp.src('.')
.pipe(webserver({
port: 9001
}));
});
gulp.task('preprocess', function () {
return gulp.src(paths.distDir + '/angular-localization.js')
.pipe(preprocess({
context: { VERSION: pkg.version }
}))
.pipe(gulp.dest(paths.distDir));
});
gulp.task('protractor', ['webdriver-update', 'connect'], function () {
gulp.src(paths.e2e)
.pipe((protractor({
configFile: 'build/protractor.conf.js'
})).on('error', function (e) {
throw e;
}))
.pipe(exit());
});
gulp.task('build', function () {
runSequence('clean', 'concat', 'preprocess', 'uglify', 'compress');
});
gulp.task('test', ['karma', 'protractor']);