-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
98 lines (82 loc) · 2.71 KB
/
gulpfile.js
File metadata and controls
98 lines (82 loc) · 2.71 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
'use strict';
var ICON_CATEGORIES = [
'action',
'alert',
'av',
'communication',
'content',
'editor',
'file',
'hardware',
'image',
'maps',
'navigation',
'notification',
'places',
'social',
'toggle'
];
var gulp = require('gulp'),
$ = require('gulp-load-plugins')(),
args = require('yargs').argv,
runSequence = require('run-sequence'),
merge = require('merge-stream'),
del = require('del');
var nextVersion = "";
gulp.task('clean', function () {
return del([
'dist/**/*'
]);
});
gulp.task('setversion', function () {
return gulp.src(['./package.json', './package-lock.json'])
.pipe($.bump({type: args.publish || 'patch'}))
.pipe($.tap(function(file){
var json = JSON.parse(String(file.contents));
nextVersion = json.version;
}));
});
gulp.task('saveversion', function () {
return gulp.src(['./package.json', './package-lock.json'])
.pipe($.bump({type: args.publish || 'patch'}))
.pipe(gulp.dest('./'));
});
gulp.task('tagversion', ['saveversion'], function () {
return gulp.src(['./package.json', './package-lock.json', './dist/**/*'])
.pipe($.git.add())
.pipe($.git.commit('publish version ' + nextVersion))
.pipe($.filter(['./package.json', './package-lock.json']))
.pipe($.tagVersion());
});
gulp.task('build', ['clean', 'setversion'], function() {
var merged = merge();
merged.add(gulp.src('./lib/*.js')
.pipe(gulp.dest('./dist/lib')));
merged.add(gulp.src('./icons/iconic/*.svg')
.pipe(gulp.dest('./dist/icons/iconic')));
merged.add(gulp.src('./node_modules/open-iconic/svg/*.svg')
.pipe(gulp.dest('./dist/icons/open-iconic')));
merged.add(gulp.src('./node_modules/ionicons/dist/svg/*.svg')
.pipe(gulp.dest('./dist/icons/ionicons')));
ICON_CATEGORIES.forEach(function(cat) {
merged.add(gulp.src('./node_modules/material-design-icons/' + cat + '/svg/production/*_24px.svg')
.pipe($.rename(function (path) {
path.basename = path.basename.replace("ic_", "").replace("_24px", "").replace(/_/g, "-");
}))
.pipe(gulp.dest('./dist/icons/material-icons')));
});
merged.add(gulp.src('./src/**/*.js')
// update CDNs
.pipe($.replace(/https:\/\/cdn\.jsdelivr\.net\/angular-icons\/0\.0\.0/g, 'https://cdn.jsdelivr.net/angular-icons/' + nextVersion))
.pipe($.replace(/https:\/\/npmcdn\.com\/angular-icons@0\.0\.0/g, 'https://npmcdn.com/angular-icons@' + nextVersion))
.pipe($.replace(/https:\/\/unpkg\.com\/angular-icons@0\.0\.0/g, 'https://unpkg.com/angular-icons@' + nextVersion))
.pipe(gulp.dest('./dist')));
return merged;
});
gulp.task('default', ['build'], function(cb) {
if (args.publish) {
return runSequence('tagversion', cb);
} else {
cb();
}
});