-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgulpfile.js
More file actions
98 lines (80 loc) · 2.19 KB
/
gulpfile.js
File metadata and controls
98 lines (80 loc) · 2.19 KB
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
// TODO: Convert to using gulpfile.babel.js
require("babel-core/register")
var _ = require("lodash")
var gulp = require("gulp")
var del = require("del")
var $ = require("gulp-load-plugins")()
var runSequence = require("run-sequence")
gulp.task("build", function() {
return gulp.src("src/**/*.js")
.pipe($.babel())
.pipe(gulp.dest("lib"))
})
gulp.task("lint", function() {
return gulp.src("src/**/*.js")
.pipe($.eslint())
.pipe($.eslint.format())
})
gulp.task("test", function() {
process.env.NODE_ENV = "test"
return gulp.src("test/**/*.js")
.pipe($.mocha({
reporter: "spec",
clearRequireCache: true,
ignoreLeaks: true
}))
})
gulp.task("watch", function() {
gulp.watch(["./src/**/*.js"], function() {
runSequence("build", "dist")
})
})
gulp.task("clean", function(cb) {
return del(["dist"], cb)
})
gulp.task("dist", function() {
return gulp.src(["lib/*", "package.json", "LICENSE", "README.md"])
.pipe(gulp.dest("dist"))
})
gulp.task("default", function(cb) {
return runSequence("build", "dist", "watch", cb)
})
function bump(importance) {
return new Promise(function(resolve) {
// Select package.json
gulp.src(["package.json"])
// Bump version on the package.json
.pipe($.bump({type: importance}))
.pipe(gulp.dest("./"))
// Commit the changes
.pipe($.git.commit("Bump version"))
// Tag our version
.pipe($.tagVersion())
.on("end", function() {
resolve()
})
})
}
gulp.task("release", function(cb) {
$.git.push("origin", "master", {args: "--follow-tags"}, function() {
gulp.src("")
.pipe($.shell([
`npm publish ./dist`
]))
.on("end", function() {
cb()
})
})
})
gulp.task("bump:minor", _.partial(bump, "minor"))
gulp.task("bump:major", _.partial(bump, "major"))
gulp.task("bump:patch", _.partial(bump, "patch"))
gulp.task("release:major", function(cb) {
runSequence("build", "bump:major", "dist", "release", "clean", cb)
})
gulp.task("release:minor", function(cb) {
runSequence("build", "bump:minor", "dist", "release", "clean", cb)
})
gulp.task("release:patch", function(cb) {
runSequence("build", "bump:patch", "dist", "release", "clean", cb)
})