-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
111 lines (90 loc) · 2.43 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
/*
* Requirements
*/
var gulp = require('gulp'),
argv = require('yargs').argv;
// Gulp plugins
var concat = require('gulp-concat'),
clean = require('gulp-clean'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
bump = require('gulp-bump'),
git = require('gulp-git');
/*
* Paths
*/
var paths = {
deps: [
'vendor/handlebars/handlebars.min.js',
'vendor/messageformat/messageformat.js',
'vendor/messageformat/locale/*'
],
header: 'src/header.js',
src: 'src/mayocat.js',
tmp: 'dist/.tmp',
dest: 'dist',
release: [
'bower.json',
'package.json'
],
};
/*
* Build tasks
*/
gulp.task('minify-deps', function() {
return gulp.src(paths.deps)
.pipe(uglify())
.pipe(concat('deps.min.js'))
.pipe(gulp.dest(paths.tmp));
});
gulp.task('minify-src', function() {
return gulp.src(paths.src)
.pipe(uglify())
.pipe(rename('src.min.js'))
.pipe(gulp.dest(paths.tmp));
});
gulp.task('concat-js', ['minify-deps'], function() {
return gulp.src([
paths.header,
paths.tmp + '/deps.min.js',
paths.src
])
.pipe(concat('mayocat.js'))
.pipe(gulp.dest(paths.dest));
});
gulp.task('concat-min-js', ['minify-deps', 'minify-src'], function() {
return gulp.src([
paths.header,
paths.tmp + '/deps.min.js',
paths.tmp + '/src.min.js'
])
.pipe(concat('mayocat.min.js'))
.pipe(gulp.dest(paths.dest));
});
gulp.task('clean', ['minify-deps', 'minify-src', 'concat-js', 'concat-js'], function() {
return gulp.src(paths.tmp, {read: false})
.pipe(clean());
});
gulp.task('default', ['minify-deps', 'minify-src', 'concat-js', 'concat-min-js', 'clean']);
/*
* Release tasks
*/
gulp.task('bump', function() {
return gulp.src(paths.release)
.pipe(bump({version: argv.ver}))
.pipe(gulp.dest('./'));
});
gulp.task('commit', ['bump'], function() {
return gulp.src(paths.release)
.pipe(git.commit('Release v' + argv.ver));
});
gulp.task('tag', ['bump', 'commit'], function() {
var version = 'v' + argv.ver;
return git.tag(version, 'Release ' + version);
});
gulp.task('push', ['bump', 'commit', 'tag'], function() {
return git.push('origin', 'master', {
args: '--tags'
}).end();
});
gulp.task('release', ['default', 'bump', 'commit', 'tag', 'push']);