From ad4f8659b01e73cff0737cc9638c6c0f0e0a3796 Mon Sep 17 00:00:00 2001 From: codecalm Date: Sat, 17 Feb 2024 20:26:51 +0100 Subject: [PATCH] update icons --- .build/helpers.mjs | 22 +++++++++++++++ .build/update-icons-unicode.mjs | 47 --------------------------------- .build/update-icons-version.mjs | 9 +++---- .build/update-icons.mjs | 46 ++++++++++++++++++++++++++++++++ .vscode/settings.json | 16 +++++------ package.json | 5 ++-- 6 files changed, 81 insertions(+), 64 deletions(-) delete mode 100644 .build/update-icons-unicode.mjs create mode 100644 .build/update-icons.mjs diff --git a/.build/helpers.mjs b/.build/helpers.mjs index a46b7e5db..9dede2b14 100644 --- a/.build/helpers.mjs +++ b/.build/helpers.mjs @@ -507,3 +507,25 @@ export const convertIconsToImages = async (dir, extension, size = 240) => { }) }) } + + +export const getMaxUnicode = () => { + const files = globSync(path.join(ICONS_SRC_DIR, '**/*.svg')) + let maxUnicode = 0 + + files.forEach(function (file) { + const svgFile = fs.readFileSync(file).toString() + + svgFile.replace(/unicode: "([a-f0-9.]+)"/i, function (m, unicode) { + const newUnicode = parseInt(unicode, 16) + + if (newUnicode) { + maxUnicode = Math.max(maxUnicode, newUnicode) + } + }) + }) + + console.log(`Max unicode: ${maxUnicode}`) + + return maxUnicode +} diff --git a/.build/update-icons-unicode.mjs b/.build/update-icons-unicode.mjs deleted file mode 100644 index 4248d93d5..000000000 --- a/.build/update-icons-unicode.mjs +++ /dev/null @@ -1,47 +0,0 @@ -import { globSync, glob } from 'glob' -import fs from 'fs' -import path from 'path' -import { ICONS_SRC_DIR } from './helpers.mjs' - -const getMaxUnicode = () => { - const files = globSync(path.join(ICONS_SRC_DIR, '**/*.svg')) - let maxUnicode = 0 - - files.forEach(function(file) { - const svgFile = fs.readFileSync(file).toString() - - svgFile.replace(/unicode: "([a-f0-9.]+)"/i, function(m, unicode) { - const newUnicode = parseInt(unicode, 16) - - if (newUnicode) { - maxUnicode = Math.max(maxUnicode, newUnicode) - } - }) - }) - - return maxUnicode -} - -let maxUnicode = getMaxUnicode() - -console.log(`Max unicode: ${maxUnicode}`) - -const files = globSync(path.join(ICONS_SRC_DIR, '**/*.svg')) - -files.forEach(function(file) { - let svgFile = fs.readFileSync(file).toString() - - if (!svgFile.match(/\nunicode: "?([a-f0-9.]+)"?/i)) { - maxUnicode++ - const unicode = maxUnicode.toString(16) - - if (unicode) { - svgFile = svgFile.replace(/-->\n/i, function(m) { + svgFile = svgFile.replace(/-->\n\n\n