aboutsummaryrefslogtreecommitdiff
path: root/gulpfile.js
diff options
context:
space:
mode:
authorcodecalm <codecalm@gmail.com>2022-03-16 03:07:05 +0100
committercodecalm <codecalm@gmail.com>2022-03-16 03:07:05 +0100
commit59cd46598acf2c0f8a38e1083e951500cefba8a9 (patch)
tree7cec7df9a945154e79e7821f35d9e86fb62c4dd8 /gulpfile.js
parent18 new icons: `file-3d`, `file-arrow-left`, `file-arrow-right`, `file-barcode... (diff)
parentMerge pull request #192 from WinterSilence/patch-1 (diff)
downloadtabler-icons-59cd46598acf2c0f8a38e1083e951500cefba8a9.tar.xz
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'gulpfile.js')
-rw-r--r--gulpfile.js51
1 files changed, 40 insertions, 11 deletions
diff --git a/gulpfile.js b/gulpfile.js
index 037f7692..2b2c5d0f 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -18,7 +18,7 @@ const gulp = require('gulp'),
svgpath = require('svgpath'),
svgr = require('@svgr/core').default;
-let compileOptions = {
+const compileOptions = {
includeIcons: [],
strokeWidth: null,
fontForge: "fontforge"
@@ -26,28 +26,57 @@ let compileOptions = {
if (fs.existsSync('./compile-options.json')) {
try {
- let tempOptions = require('./compile-options');
- if (typeof tempOptions!="object") {
+ const tempOptions = require('./compile-options.json');
+ if (typeof tempOptions !== "object") {
throw "Compile options file does not contain an json object";
}
- if (typeof tempOptions.includeIcons!="undefined") {
+ if (typeof tempOptions.includeIcons !== "undefined") {
if (!Array.isArray(tempOptions.includeIcons)) {
throw "property inludeIcons is not an array";
}
- compileOptions.includeIcons= tempOptions.includeIcons;
+ compileOptions.includeIcons = tempOptions.includeIcons;
}
- if (typeof tempOptions.strokeWidth!="undefined") {
- if (typeof tempOptions.strokeWidth!="string" && typeof tempOptions.strokeWidth!="number") {
+
+ if (typeof tempOptions.includeCategories !== "undefined") {
+ if (typeof tempOptions.includeCategories === "string") {
+ tempOptions.includeCategories = tempOptions.includeCategories.split(' ');
+ }
+ if (!Array.isArray(tempOptions.includeCategories)) {
+ throw "property includeCategories is not an array or string";
+ }
+ const tags = Object.entries(require('./tags.json'));
+ tempOptions.includeCategories.forEach(function (category) {
+ category = category.charAt(0).toUpperCase() + category.slice(1);
+ for (const [icon, data] of tags) {
+ if (data.category === category && compileOptions.includeIcons.indexOf(icon) === -1) {
+ compileOptions.includeIcons.push(icon);
+ }
+ }
+ });
+ }
+
+ if (typeof tempOptions.excludeIcons !== "undefined") {
+ if (!Array.isArray(tempOptions.excludeIcons)) {
+ throw "property excludeIcons is not an array";
+ }
+ compileOptions.includeIcons = compileOptions.includeIcons.filter(function (icon) {
+ return tempOptions.excludeIcons.indexOf(icon) === -1;
+ });
+ }
+
+ if (typeof tempOptions.strokeWidth !== "undefined") {
+ if (typeof tempOptions.strokeWidth !== "string" && typeof tempOptions.strokeWidth !== "number") {
throw "property strokeWidth is not a string or number";
}
- compileOptions.strokeWidth=tempOptions.strokeWidth.toString();
+ compileOptions.strokeWidth = tempOptions.strokeWidth.toString();
}
- if (typeof tempOptions.fontForge!="undefined") {
- if (typeof tempOptions.fontForge!="string") {
+
+ if (typeof tempOptions.fontForge !== "undefined") {
+ if (typeof tempOptions.fontForge !== "string") {
throw "property fontForge is not a string";
}
- compileOptions.fontForge=tempOptions.fontForge;
+ compileOptions.fontForge = tempOptions.fontForge;
}
} catch (error) {