-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
gulpFile.js
98 lines (79 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
var gulp = require('gulp'),
git = require('gulp-git'),
bump = require('gulp-bump'),
filter = require('gulp-filter'),
tag_version = require('gulp-tag-version'),
runSequence = require('run-sequence').use(gulp),
spawn = require('child_process').spawn,
coffee = require('gulp-coffee'),
gutil = require('gulp-util'),
uglify = require("gulp-uglify"),
rename = require('gulp-rename'),
sourcemaps = require('gulp-sourcemaps'),
concat = require('gulp-concat'),
minifyCSS = require('gulp-minify-css'),
serve = require('gulp-serve');
gulp.task('makeCss', function() {
gulp.src('./dist/pivot.css')
.pipe(minifyCSS())
.pipe(concat('pivot.min.css'))//trick to output to new file
.pipe(gulp.dest('./dist/'))
});
gulp.task('makeJs', function() {
gulp.src(['./src/*.coffee', './locales/*.coffee', './tests/*.coffee'])
//compile to js (and create map files)
.pipe(sourcemaps.init())
.pipe(coffee()).on('error', gutil.log)
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist'))
//minify js files as well
.pipe(filter('*.js'))//filter, to avoid doing this processing on the map files generated above
.pipe(rename({
suffix: '.min'
}))
.pipe(sourcemaps.init({loadMaps: true}))//load the source maps generated in the first step
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist'));
});
function inc(importance) {
// get all the files to bump version in
return gulp.src(['./package.json', './bower.json', './pivottable.jquery.json'])
// bump the version number in those files
.pipe(bump({type: importance}))
// save it back to filesystem
.pipe(gulp.dest('./'));
}
gulp.task('publish', function (done) {
spawn('npm', ['publish'], { stdio: 'inherit' }).on('close', done);
});
gulp.task('push', function (done) {
git.push('origin', 'master', {args: '--tags'}, function (err) {
if (err) throw err;
});
});
gulp.task('tag', function() {
return gulp.src(['./package.json', './bower.json', './pivottable.jquery.json'])
.pipe(git.commit('version bump'))
// read only one file to get the version number
.pipe(filter('package.json'))
.pipe(tag_version());
});
gulp.task('bumpPatch', function() { return inc('patch'); })
gulp.task('bumpMinor', function() { return inc('minor'); })
gulp.task('bumpMajor', function() { return inc('major'); })
gulp.task('patch', function() {
runSequence('bumpPatch', 'default', 'tag', 'publish', 'push');
});
gulp.task('minor', function() {
runSequence('bumpMinor', 'default', 'tag', 'publish', 'push');
});
gulp.task('major', function() {
runSequence('bumpMajor', 'default', 'tag', 'publish', 'push');
});
gulp.task('serve', serve('.'));
gulp.task('watch', function() {
gulp.watch(['./src/*.coffee', './locales/*.coffee', './tests/*.coffee'], ['makeJs']);
gulp.watch('./dist/pivot.css', ['makeCss']);
});
gulp.task('default', ['makeJs', 'makeCss']);