-
Notifications
You must be signed in to change notification settings - Fork 18
/
gulpfile.js
84 lines (67 loc) · 2.85 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
var requireDir = require('require-dir');
var dir = requireDir('./node_modules/joomla-gulp', {recurse: true});
var dir = requireDir('./joomla-gulp', {recurse: true});
// Load config
var extension = require('./package.json');
var config = require('./gulp-config.json');
var gulp = require('gulp');
var zip = require('gulp-zip');
var rm = require('gulp-rimraf');
var replace = require('gulp-replace');
var es = require('event-stream');
//release
gulp.task('cleanRelease', function () {
return gulp.src('./releases', { read: false }).pipe(rm({ force: true }));
});
var modelFolders = [
'com_digicom',
'mod_digicom_cart',
'mod_digicom_categories',
'mod_digicom_menu',
'plg_content_digicom',
'plg_digicom_pay_offline',
'plg_digicom_pay_paypal',
'plg_editors-xtd_digicom',
'plg_finder_digicom',
'plg_system_digicom',
];
// identifies a dependent task must be complete before this one begins
gulp.task('release', ['cleanRelease'], function() {
var zips = [], modelZip;
for (var i = 0; i < modelFolders.length; i++) {
var model = modelFolders[i];
if(model == 'com_digicom'){
var component = [], modofiedapp, completeapp;
completeapp = gulp.src(
'./src/'+ model+'/media/**', {base: './src/com_digicom/'}
);
modofiedapp = gulp.src([
'./src/'+ model+'/**',
'!./src/'+ model+'/media/**',
])
.pipe(replace(/##DIGICOM_VERSION##/g, extension.version))
.pipe(replace(/##DIGICOM_CREATIONDATE##/g, extension.creationDate));
component.push(completeapp);
component.push(modofiedapp);
component = es.merge.apply(null, component)
modelZip = component.pipe(zip(model + '.zip'));
}else{
modelZip = gulp.src('./src/'+ model+'/**')
.pipe(replace(/##DIGICOM_VERSION##/g, extension.version))
.pipe(replace(/##DIGICOM_CREATIONDATE##/g, extension.creationDate))
.pipe(zip(model + '.zip'));
}
// notice we removed the dest step and store the zip stream (still in memory)
zips.push(modelZip);
}
var pkgfiles = gulp.src(['!*', './src/pkg_language/**', './src/pkg.script.php', './src/pkg_digicom.xml'])
// run the replacement of version name
.pipe(replace(/##DIGICOM_VERSION##/g, extension.version))
// run the replacement of creation date
.pipe(replace(/##DIGICOM_CREATIONDATE##/g, extension.creationDate));
zips.push(pkgfiles);
// we finally merge them (the zips), zip them again, and output.
return es.merge.apply(null, zips)
.pipe(zip(extension.name + '_' + extension.version + '.zip'))
.pipe(gulp.dest('releases'));
});