-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGulpfile.js
112 lines (86 loc) · 3.28 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
/*jshint node:true */
"use strict";
var gulp = require('gulp');
var clean = require('./gulpLib/clean');
var version = require('./gulpLib/version');
var test = require('./gulpLib/test');
var build = require('./gulpLib/build');
var deploy = require('./gulpLib/deploy');
var opts = {
buildVersion: require('./package.json').version,
buildNumber: process.env.BUILD_NUMBER,
copyrightHeader: 'Copyright {{year}} MyCompany, All Rights Reserved',
deployLocation: './deployDir',
verbose: true
};
opts.headerText = '/*! {{copyrightHeader}}\r\n Hash: {{gitHash}}\r\n Version: {{buildVersion}}\r\n Branch: {{gitBranch}}\r\n Build: {{buildNumber}}\r\n Build date: {{now}} */';
opts.doDeploy = !!process.env.BUILD_NUMBER; // FRAGILE: ASSUME: If we have no build number we're not on the CI server
gulp.env.silent = !opts.verbose;
opts.jshint = {
"evil": false,
"regexdash": false,
"browser": false,
"wsh": false,
"trailing": false,
"sub": false,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"forin": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"noempty": true,
"nonew": true,
"regexp": true,
"undef": true,
"unused": true,
"strict": true
};
opts.mocha = {
};
// stop the build on a task failure
gulp.on('err', function (e) {
console.log();
console.log('Gulp build failed: '+e.message);
process.exit(1);
});
var noop = function () {};
// default task gets called when you run `gulp` with no arguments
gulp.task('default', ['clean', 'version', 'test', 'build', 'deploy'], noop);
// The main 5 steps:
gulp.task('clean', ['cleanVersioned', 'cleanUnversioned', 'cleanNodeModules'], noop);
gulp.task('version', ['getGitHash', 'getGitBranch'], noop);
gulp.task('test', ['clean', 'runJSHint', 'runMocha'], noop);
gulp.task('build', ['clean','test','minifyJavaScript', 'copyContentToDist', 'copyModulesToDist', 'shrinkwrapDist', 'setGitInPackageJson'], noop);
gulp.task('deploy', ['test','build', 'copyToDeployLocation', 'tagGit'], noop);
// clean
gulp.task('cleanUnversioned', ['setOpts'], clean.cleanUnversioned);
gulp.task('cleanVersioned', ['setOpts'], clean.cleanVersioned);
gulp.task('cleanNodeModules', clean.cleanNodeModules);
// version
gulp.task('getGitHash', ['setOpts'], version.getGitHash);
gulp.task('getGitBranch', ['setOpts'], version.getGitBranch);
// test
gulp.task('runJSHint', ['setOpts', 'clean'], test.runJSHint);
gulp.task('runMocha', ['clean'], test.runMocha);
gulp.task('runNpmTest', ['clean'], test.runNpmTest); // FRAGILE: This can get recursive
// build
gulp.task('minifyJavaScript', ['clean', 'version', 'setOpts'], build.minifyJavaScript);
gulp.task('copyContentToDist', ['clean', 'setOpts'], build.copyContentToDist);
gulp.task('copyModulesToDist', ['clean', 'setOpts'], build.copyModulesToDist);
gulp.task('shrinkwrapDist', ['clean', 'setOpts', 'copyModulesToDist', 'copyContentToDist'], build.shrinkwrapDist);
gulp.task('setGitInPackageJson', ['clean', 'version', 'setOpts'], build.setGitInPackageJson);
// deploy
gulp.task('copyToDeployLocation', ['setOpts','test','build'], deploy.copyToDeployLocation);
gulp.task('tagGit', ['setOpts', 'test','build'], deploy.tagGit);
// generic
gulp.task('setOpts', function () {
clean.setOpts(opts);
version.setOpts(opts);
build.setOpts(opts);
test.setOpts(opts);
deploy.setOpts(opts);
});