-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
160 lines (142 loc) · 3.69 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
'use strict';
var gulp = require('gulp'),
karma = require('karma'),
git = require('gulp-git'),
bump = require('gulp-bump'),
sass = require('gulp-sass'),
gzip = require('gulp-gzip'),
cssmin = require('gulp-cssmin'),
jshint = require('gulp-jshint'),
concat = require('gulp-concat'),
ugly = require('gulp-uglify'),
header = require('gulp-header'),
filter = require('gulp-filter'),
bsync = require('browser-sync'),
pkg = require('./package.json'),
tagVersion = require('gulp-tag-version'),
autoprefixer = require('gulp-autoprefixer');
var files = {
karma: [
'node_modules/angular/angular.js',
'node_modules/angular-mocks/angular-mocks.js'
],
test: [
'test/**/*.spec.js'
],
js: [
'src/ng-i18n-provider.js',
'src/ng-i18n-directive.js',
'src/ng-i18n-filter.js'
],
sass: [
'demo/assets/sass/demo.scss',
'bower_components/flag-icon-css/sass/flag-icon.scss'
]
};
var banner = [
'/*',
'<%= pkg.name %> - <%= pkg.repository.url %>',
'Version: <%= pkg.version %>',
'Author: <%= pkg.authors[0] %>',
'*/',
''
].join('\n');
gulp.task('watch', function() {
gulp.watch(['src/**/*.js', 'demo/assets/demo.js'], ['lint', 'js']);
gulp.watch('demo/index.html', bsync.reload);
gulp.watch(files.sass, ['css']);
});
gulp.task('css', function() {
return gulp.src(files.sass)
.pipe(sass())
.pipe(autoprefixer({
cascade: true
}))
.pipe(cssmin())
.pipe(header(banner, {
pkg: pkg,
now: new Date()
}))
.pipe(gulp.dest('demo/assets'))
.pipe(bsync.reload({
stream: true
}));
});
gulp.task('karma', function (done) {
new karma.Server.start({
configFile: __dirname + '/karma.conf.js'
}, done);
});
gulp.task('test', function (done) {
new karma.Server.start({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done);
});
gulp.task('lint', function() {
return gulp.src(files.js)
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('js', function() {
return gulp.src(files.js)
.pipe(concat('ng-i18n.js'))
.pipe(header(banner, {
pkg: pkg,
now: new Date()
}))
.pipe(gulp.dest('dist/'))
.pipe(ugly())
.pipe(header(banner, {
pkg: pkg,
now: new Date()
}))
.pipe(concat('ng-i18n.min.js'))
.pipe(gulp.dest('dist/'))
.pipe(gulp.dest('demo/assets'))
.pipe(gzip())
.pipe(gulp.dest('dist/'))
.pipe(bsync.reload({
stream: true
}));
});
gulp.task('serve', function() {
bsync.init({
server: {
baseDir: './demo'
}
});
});
function increment(importance) {
// get all the files to bump version in
return gulp.src(['./package.json', './bower.json'])
// bump the version number in those files
.pipe(bump({
type: importance
}))
// save it back to filesystem
.pipe(gulp.dest('./'))
// commit the changed version number
.pipe(git.commit('bumps package version'))
// read only one file to get the version number
.pipe(filter('package.json'))
// **tag it in the repository**
.pipe(tagVersion());
}
gulp.task('patch', function() {
return increment('patch');
});
gulp.task('feature', function() {
return increment('minor');
});
gulp.task('release', function() {
return increment('major');
});
// Deploy the demo
gulp.task('deploy', function(){
git.exec({args : 'subtree push --prefix demo origin gh-pages'}, function (err) {
console.error('There was an error deploying to GitHub Pages\n', err);
});
});
gulp.task('default', ['js', 'watch', 'karma']);
gulp.task('demo', ['js', 'css', 'watch', 'serve']);