This repository has been archived by the owner on Nov 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Gulpfile.js
73 lines (66 loc) · 2.02 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
var del = require("del"),
gulp = require("gulp"),
runSequence = require("run-sequence"),
shell = require("gulp-shell"),
svgmin = require("gulp-svgmin"),
path = require("path"),
zip = require('gulp-zip'),
merge = require('merge-stream'),
foreach = require('gulp-foreach'),
flatten = require('gulp-flatten');
gulp.task("clean", () => {
return del([
"dist/**/*"
]);
});
gulp.task("export", shell.task([
"osascript lib/export.scpt "
+ path.resolve(__dirname, "lib/IllustratorSaveAsSvgs.jsx") + " "
+ path.resolve(__dirname, "dist") + " "
+ path.resolve(__dirname, "src") + " "
]));
gulp.task("svg", () => {
return gulp.src("dist/**/*.svg")
.pipe(svgmin())
.pipe(gulp.dest("dist"));
});
// Icon Download Tasks
gulp.task('compile-zips-all', function() {
return gulp.src(['./dist/**/!(*.json)', '!./dist/zips/'])
.pipe(zip('ibm-design-icons.zip'))
.pipe(gulp.dest('dist/zips/'))
});
gulp.task('compile-zips-individual', ['compile-zips-all'], function() {
return merge(
gulp.src('./dist/**/*_16.svg'),
gulp.src('./dist/**/*_24.svg'),
gulp.src('./dist/**/*_32.svg'),
gulp.src('./dist/**/*_64.svg'),
gulp.src('./dist/**/*_128.svg'),
gulp.src('./dist/**/glyphs/*.svg')
).pipe(
foreach(
function(stream, file) {
var iconName = function(iconPath) {
var baseName = path.basename(iconPath);
return baseName.substring(0,baseName.lastIndexOf('_'));
}(file.path);
return gulp.src(
[
'./dist/**/' + iconName + '_*',
'!./dist/zips/',
'./dist/LICENSE.md',
'./dist/README.md'
], {}
)
.pipe(flatten({newPath: './ibm-design-icons-' + iconName}))
.pipe(zip('ibm-design-icons-' + iconName + '.zip'))
.pipe(gulp.dest('dist/zips/'));
}
)
);
});
gulp.task('zips', ['compile-zips-individual']);
gulp.task("default", done => {
runSequence("clean", "export", "svg", "zips", done);
});