AFFiNE/scripts/download-blocksuite-fonts.mjs

29 lines
692 B
JavaScript
Raw Normal View History

import { writeFile } from 'node:fs/promises';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
2024-09-06 13:54:18 +03:00
import { AffineCanvasTextFonts } from '@blocksuite/blocks';
const fontPath = join(
fileURLToPath(import.meta.url),
'..',
'..',
'packages',
'frontend',
'core',
'public',
'fonts'
);
await Promise.all(
AffineCanvasTextFonts.map(async ({ url }) => {
const buffer = await fetch(url).then(res =>
res.arrayBuffer().then(res => Buffer.from(res))
);
const filename = url.split('/').pop();
const distPath = join(fontPath, filename);
await writeFile(distPath, buffer);
console.info(`Downloaded ${distPath} successfully`);
})
);