This commit is contained in:
Michel Fedde 2025-06-18 22:53:54 +02:00
parent 441715675c
commit a79898b2e9
48 changed files with 2062 additions and 1503 deletions

View file

@ -5,29 +5,30 @@ import {IconCache} from "./IconCache";
export class IconDeployer {
static ICON_PATH = path.resolve('public/icons')
constructor(
private readonly iconCache: IconCache
) {}
) {
}
public async ensureExistance() {
const directory = await fs.promises.opendir(IconDeployer.ICON_PATH);
const addIconPromises: Promise<void>[] = [];
for await (const dirname of directory) {
const iconName = path.basename(dirname.name, '.svg').replaceAll('-','_');
const iconName = path.basename(dirname.name, '.svg').replaceAll('-', '_');
if (this.iconCache.get(iconName) !== null) {
continue;
}
addIconPromises.push(
this.addIcon(path.resolve(dirname.parentPath, dirname.name), iconName)
);
}
await Promise.all(addIconPromises);
}
private async addIcon(iconPath: string, iconName: string) {
const svgBuffer = await fs.promises.readFile(iconPath, 'utf-8');
const pngBuffer = await new Promise<Buffer>(resolve => {
@ -48,8 +49,8 @@ export class IconDeployer {
)
}
)
await this.iconCache.set(iconName, pngBuffer);
}
}