MCPcopy Create free account
hub / github.com/fontsource/fontsource / getAllFiles

Function getAllFiles

packages/publish/src/hash.ts:5–23  ·  view source on GitHub ↗
(dir: string)

Source from the content-addressed store, hash-verified

3import * as path from 'pathe';
4
5const getAllFiles = async (dir: string): Promise<string[]> => {
6 const dirents = await fs.readdir(dir, { withFileTypes: true });
7 const files = await Promise.all(
8 dirents.map(async (dirent) => {
9 // If file is package.json, do not include
10 if (dirent.name === 'package.json') {
11 return [];
12 }
13 // Ignore .woff and .woff2 files
14 if (dirent.name.endsWith('.woff') || dirent.name.endsWith('.woff2')) {
15 return [];
16 }
17 const res = path.resolve(dir, dirent.name);
18 return dirent.isDirectory() ? await getAllFiles(res) : res;
19 }),
20 );
21
22 return Array.prototype.concat(...files);
23};
24
25const getHash = async (dir: string): Promise<string> => {
26 const files = await getAllFiles(dir);

Callers 2

hash.test.tsFile · 0.90
getHashFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected