Raw
1 import fs from "fs/promises"
2 import { generateHash } from "../utils"
3 import { findSearchEntityFile } from "./find-search-entity-file"
4
5 export async function generateSearchEntityHash(
6 sources: Set<string>
7 ): Promise<string> {
8 const contents: string[] = []
9
10 for (const source of sources) {
11 const searchEntitiesPath = await findSearchEntityFile(source)
12
13 if (!searchEntitiesPath) {
14 continue
15 }
16
17 try {
18 contents.push(await fs.readFile(searchEntitiesPath, "utf-8"))
19 } catch {
20 // File was removed between lookup and read.
21 }
22 }
23
24 return generateHash(contents.join(""))
25 }