forked from ManageIQ/manageiq-ui-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
135 lines (119 loc) · 4.09 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
'use strict';
var args = require('yargs').argv;
var gulp = require('gulp');
var merge = require('merge');
var taskListing = require('gulp-task-listing');
var browserSync = require('browser-sync');
var log = require('gulp-util').log;
/**
* List the available gulp tasks
*/
gulp.task('help', taskListing);
gulp.task('default', ['help']);
/**
* Check the code for errors
*/
gulp.task('jshint', task('jshint'));
gulp.task('jscs', task('jscs'));
gulp.task('plato', task('plato'));
gulp.task('vet', ['jshint', 'jscs']);
/**
* Cleans the build output
*/
gulp.task('clean', task('clean'));
gulp.task('clean-styles', task('clean', {key: 'cleanStyles'}));
gulp.task('clean-fonts', task('clean', {key: 'cleanFonts'}));
gulp.task('clean-images', task('clean', {key: 'cleanImages'}));
gulp.task('clean-code', task('clean', {key: 'cleanCode'}));
/**
* Individual component build tasks
*/
gulp.task('templatecache', task('templatecache'));
gulp.task('sass', task('sass'));
gulp.task('wiredep', task('wiredep'));
gulp.task('fonts', task('fonts'));
gulp.task('images', task('images'));
gulp.task('skin-images', ['images'], task('images', {key: 'skinImages'}));
gulp.task('imgs', ['images'], task('images', {key: 'imgs'}));
gulp.task('dev-fonts', task('fonts', {key: 'devFonts'}));
gulp.task('dev-images', task('images', {key: 'devImages'}));
gulp.task('dev-skin-images', ['dev-images'], task('images', {key: 'devSkinImages'}));
gulp.task('dev-imgs', task('images', {key: 'devImgs'}));
gulp.task('gettext-extract', task('gettext-extract'));
gulp.task('gettext-compile', task('gettext-compile'));
gulp.task('gettext-copy', ['available-languages'], task('gettext-copy'));
gulp.task('console-copy', task('console-copy'));
gulp.task('available-languages', task('available-languages'));
/**
* Build tasks
*/
gulp.task('inject', ['wiredep', 'sass', 'templatecache'], task('inject'));
gulp.task('optimize', ['inject'], task('optimize'));
gulp.task('build', ['optimize', 'images', 'imgs', 'skin-images', 'fonts', 'gettext-copy', 'console-copy', 'available-languages'], task('build'));
gulp.task('build-specs', ['templatecache'], task('buildSpecs'));
/**
* Testing tasks
*/
gulp.task('test', ['vet', 'templatecache'], task('test', {singleRun: true}));
gulp.task('testonly', ['templatecache'], task('test', {singleRun: true}));
gulp.task('autotest', task('test', {singleRun: false}));
/**
* Serves up injected html for dev, builds for evything else.
*/
gulp.task('serve-dev', ['dev-fonts', 'dev-images', 'dev-skin-images', 'dev-imgs', 'inject', 'available-languages'], task('serve', {
isDev: true,
specRunner: false
}));
gulp.task('serve-build', ['build'], task('serve', {
isDev: false,
specRunner: false
}));
gulp.task('serve-specs', ['build-specs'], task('serve', {
isDev: true,
specRunner: true
}));
/**
* Bump the version
* --type=pre will bump the prerelease version *.*.*-x
* --type=patch or no flag will bump the patch version *.*.x
* --type=minor will bump the minor version *.x.*
* --type=major will bump the major version x.*.*
* --version=1.2.3 will bump to a specific version and ignore other flags
*/
gulp.task('bump', task('bump'));
function errorHandler(error) {
browserSync.notify(error.message, 3000);
log('[Error!] ' + error.toString());
if (process.argv.indexOf('--fail') !== -1) {
process.exit(1);
}
}
function argOptions() {
return {
rev: !!(args.rev || args.production),
minify: !!(args.minify || args.production),
production: !!args.production,
verbose: !!(args.verbose || args.v),
startServer: !!args.startServer,
debug: !!(args.debug || args.debugBrk),
debugBrk: !!args.debugBrk,
nosync: !!args.nosync,
type: args.type,
version: args.version
};
}
function task(taskName, options) {
var actualErrorHandler;
if (typeof options !== 'object') {
options = {};
}
if (typeof options.onError !== 'function') {
options.onError = errorHandler;
}
actualErrorHandler = options.onError;
options.onError = function() {
actualErrorHandler.apply(this, arguments);
this.emit('end');
};
return require('./gulp/tasks/' + taskName)(gulp, merge(argOptions(), options));
}