Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 30 additions & 26 deletions build/icon-font.mjs
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
import fs from "node:fs/promises";
import path from "node:path";
// DANGER: This file is ignored because it requires the "webfont" package, which has
// been compromised to some extent through https://www.aikido.dev/blog/npm-debug-and-chalk-packages-compromised.
// Ideally, we will replace this with a safer alternative in the future, or restore when the package is fixed.

import { webfont } from "webfont";
// import fs from "node:fs/promises";
// import path from "node:path";

const svgsDir = path.resolve(`${import.meta.dirname}/../resources/icons`);
const svgs = await fs
.readdir(svgsDir)
.then((files) => files.filter((file) => file.endsWith(".svg")))
.then((files) => files.map((file) => `${svgsDir}/${file}`));
// import { webfont } from "webfont";

const dest = `${import.meta.dirname}/../resources/fonts/localstack.woff`;
// const svgsDir = path.resolve(`${import.meta.dirname}/../resources/icons`);
// const svgs = await fs
// .readdir(svgsDir)
// .then((files) => files.filter((file) => file.endsWith(".svg")))
// .then((files) => files.map((file) => `${svgsDir}/${file}`));

async function generateFont() {
try {
const result = await webfont({
files: svgs,
formats: ["woff"],
startUnicode: 0xe000,
normalize: true,
sort: false,
});
await fs.mkdir(path.dirname(dest), { recursive: true });
await fs.writeFile(dest, result.woff, "binary");
console.log(`Font created at ${path.relative(process.cwd(), dest)}`);
} catch (error) {
console.error("Font creation failed.", error);
}
}
// const dest = `${import.meta.dirname}/../resources/fonts/localstack.woff`;

await generateFont();
// async function generateFont() {
// try {
// const result = await webfont({
// files: svgs,
// formats: ["woff"],
// startUnicode: 0xe000,
// normalize: true,
// sort: false,
// });
// await fs.mkdir(path.dirname(dest), { recursive: true });
// await fs.writeFile(dest, result.woff, "binary");
// console.log(`Font created at ${path.relative(process.cwd(), dest)}`);
// } catch (error) {
// console.error("Font creation failed.", error);
// }
// }

// await generateFont();
Loading
Loading