This repository has been archived by the owner on Dec 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
99 lines (82 loc) · 2.49 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
'use strict';
var fs = require('fs');
var gulp = require('gulp');
var istanbul = require('gulp-istanbul');
var jasmine = require('gulp-jasmine');
var eslint = require('gulp-eslint');
var coveralls = require('gulp-coveralls');
var publish = require('publish-please');
var conventionalChangelog = require('gulp-conventional-changelog');
var git = require('gulp-git');
var bump = require('gulp-bump');
var SOURCE_CODE = ['app/*.js', 'spec/*.js', 'models/*.js', 'handlers/*.js', 'lib/*.js'];
var TEST_CODE = ['test/*.js'];
var version = 'v' + JSON.parse(fs.readFileSync('./package.json')).version;
gulp.task('pre-test', function () {
return gulp.src(SOURCE_CODE)
// Covering files
.pipe(istanbul())
// Force `require` to return covered files
.pipe(istanbul.hookRequire());
});
gulp.task('test', ['lint'], function () {
return gulp.src(TEST_CODE)
.pipe(jasmine());
});
gulp.task('cover', ['lint', 'pre-test'], function () {
return gulp.src(TEST_CODE)
.pipe(jasmine())
// Creating the reports after tests ran
.pipe(istanbul.writeReports());
});
gulp.task('lint', function () {
return gulp.src(SOURCE_CODE)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('coveralls', function () {
return gulp.src('coverage/lcov.info')
.pipe(coveralls());
});
gulp.task('changelog', function () {
return gulp.src('CHANGELOG.md', {
buffer: false
})
.pipe(conventionalChangelog({
preset: 'angular',
releaseCount: 0
}))
.pipe(gulp.dest('./'));
});
function inc(importance) {
// get all the files to bump version in
return gulp.src(['./package.json'])
// bump the version number in those files
.pipe(bump({type: importance}))
// save it back to filesystem
.pipe(gulp.dest('./'));
}
gulp.task('bump-patch', function() {
return inc('patch');
});
gulp.task('bump-feature', function() {
return inc('minor');
});
gulp.task('bump-release', function() {
return inc('major');
});
gulp.task('commit-release', ['changelog'], function () {
return gulp.src(['./package.json', './CHANGELOG.md'])
.pipe(git.commit('chore(release): Release ' + version));
});
gulp.task('tag-release', ['commit-release'], function () {
git.tag(version, 'Release ' + version, function (err) {
if (err) {
throw err;
}
});
});
gulp.task('pub-release', ['test'], function () {
return publish();
});