-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgulpfile.js
More file actions
80 lines (69 loc) · 2.36 KB
/
gulpfile.js
File metadata and controls
80 lines (69 loc) · 2.36 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
(function () {
"use strict";
var gulp = require("gulp");
var args = require("yargs").argv;
var pkg = require("./package.json");
var config = require("./gulp.config")();
var _ = require("lodash");
var $ = require("gulp-load-plugins")({lazy: true});
var banner = "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> \n" +
"<%= pkg.homepage ? '* ' + pkg.homepage + '\\n' : '' %>" +
"* Copyright (c) <%= pkg.author.name %>\n*/\n";
var frontendSources = ["aspects/**/*.module.js", "aspects/**/*.js"];
var allSources = _.union(frontendSources, ["application/**/*.js"]);
gulp.task("help", $.taskListing);
gulp.task("default", ["help"]);
gulp.task("build", buildTask);
gulp.task("watch", watchTask);
gulp.task("jshint", hintTask);
gulp.task("bump", bumpTask);
///////////// Tasks
function buildTask() {
return gulp.src(frontendSources)
.pipe($.sourcemaps.init())
.pipe($.concat("dist.min.js"))
.pipe($.uglify({ mangle: false }))
.pipe($.sourcemaps.write())
.pipe($.header(banner, {pkg: pkg}))
.pipe(gulp.dest("./public/"));
}
function watchTask() {
gulp.watch(allSources, ["default", "jshint"]);
}
function hintTask() {
return gulp.src(allSources)
.pipe($.jshint())
.pipe($.jshint.reporter('default'));
}
function bumpTask() {
var msg = "Bumping versions";
var type = args.type;
var version = args.version;
var options = {};
if (version) {
options.version = version;
msg += " to " + version;
} else {
options.type = type;
msg += " for a " + type;
}
log(msg);
return gulp
.src(config.packages)
.pipe($.print())
.pipe($.bump(options))
.pipe(gulp.dest(config.root));
}
///////////// Helpers
function log(msg) {
if (typeof(msg) === "object") {
for (var item in msg) {
if (msg.hasOwnProperty(item)) {
$.util.log($.util.colors.blue(msg[item]));
}
}
} else {
$.util.log($.util.colors.blue(msg));
}
}
})();