This repository has been archived by the owner on May 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathGulpfile.js
101 lines (77 loc) · 2.92 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';
//////////////////////////////////////////////////////////////////////////////
// REQUIRED
//////////////////////////////////////////////////////////////////////////////
var gulp = require('gulp');
var path = require('path');
var cm = require('./lib/common');
var publish = require('./lib/publish');
var build = require('./lib/build');
//////////////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////////////
gulp.task('clean', function(done) {
var rimraf = require('gulp-rimraf');
var DIR = cm.component_publisher_dir;
gulp.src(DIR + '/**').pipe(rimraf())
.on('end', done);
});
gulp.task('build_gh-pages', build.ghpages);
gulp.task('build_bower', function(done){
build.bower(done, cm.public.bowerData);
});
gulp.task('build_subbower', function(done){
var moduleNames = Object.keys(cm.public.subcomponents);
var almostDone = cm._.after(moduleNames.length, done);
for (var i = 0, n = moduleNames.length; i < n ; i++){
build.subbower(moduleNames[i], cm.public.subcomponents[moduleNames[i]])(almostDone);
}
});
var allowPushOnRepo = (process.env.TRAVIS == 'true') && (process.env.TRAVIS_PULL_REQUEST == 'false') && true;
gulp.task('publish_gh-pages', function(cb){
if (process.env.TRAVIS){
publish.apply(this, [{
tag: false,
push: allowPushOnRepo && /^master$/.test(process.env.TRAVIS_BRANCH),
message: 'Travis commit : build ' + process.env.TRAVIS_BUILD_NUMBER
}, cb]);
}else{
publish.apply(this, [cb]);
}
});
gulp.task('publish_bower', function(cb){
if (process.env.TRAVIS){
publish.apply(this, [
{
push: allowPushOnRepo && /^src\d+\.\d+\.\d+.*$/.test(process.env.TRAVIS_BRANCH),
message: 'Travis commit : build ' + process.env.TRAVIS_BUILD_NUMBER
}, cb]);
}else{
publish.apply(this, [cb]);
}
});
gulp.task('publish_subbower', function(done){
var moduleNames = Object.keys(cm.public.subcomponents);
var almostDone = cm._.after(moduleNames.length, done);
for (var i = 0, n = moduleNames.length; i < n ; i++){
var mName = moduleNames[i];
publish.apply(this, [{
branch: 'bower-' + mName,
cloneLocation: path.resolve(path.join(process.cwd(), cm.PUBLISH_DIR, 'subbower', mName)),
dirSrc: path.resolve(path.join(process.cwd(), cm.BUILD_DIR, 'subbower', mName)),
message: 'Travis commit : build ' + process.env.TRAVIS_BUILD_NUMBER,
push: allowPushOnRepo && /^src\d+\.\d+\.\d+.*$/.test(process.env.TRAVIS_BRANCH),
tag: mName + '-' + cm.pkg.version
}, almostDone]);
}
});
function prefixedBranchedTasks(prefix){
gulp.task(prefix, function(cb){
if (!cm.env.branch )
throw new Error('\nJust say want you want to ' + prefix + ' like\n' + prefix + ' --branch=bower');
// TODO test if exist ?
cm.run(prefix + '_' + cm.env.branch, cb);
});
}
prefixedBranchedTasks('build');
prefixedBranchedTasks('publish');