AFFiNE/scripts/download-blocksuite-fonts.mjs

30 lines
776 B
JavaScript
Raw Normal View History

import { writeFile } from 'node:fs/promises';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
2024-02-19 17:03:26 +03:00
import { CanvasTextFonts } from '@blocksuite/blocks/dist/surface-block/consts.js';
const fontPath = join(
fileURLToPath(import.meta.url),
'..',
'..',
'packages',
'frontend',
'web',
'dist',
'assets'
);
await Promise.all(
2024-02-19 17:03:26 +03:00
CanvasTextFonts.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`);
})
);