MCPcopy Create free account
hub / github.com/expo/eas-cli / hashFiles

Function hashFiles

packages/steps/src/utils/hashFiles.ts:9–34  ·  view source on GitHub ↗
(filePaths: string[])

Source from the content-addressed store, hash-verified

7 * @returns Combined SHA256 hash of all files, or empty string if no files exist
8 */
9export function hashFiles(filePaths: string[]): string {
10 const combinedHash = createHash('sha256');
11 let hasFound = false;
12
13 for (const filePath of filePaths) {
14 try {
15 if (fs.pathExistsSync(filePath)) {
16 const fileContent = fs.readFileSync(filePath);
17 const fileHash = createHash('sha256').update(new Uint8Array(fileContent)).digest();
18 combinedHash.write(fileHash);
19 hasFound = true;
20 }
21 } catch (err: any) {
22 throw new Error(`Failed to hash file ${filePath}: ${err.message}`);
23 }
24 }
25
26 combinedHash.end();
27 const result = combinedHash.digest('hex');
28
29 if (!hasFound) {
30 return '';
31 }
32
33 return result;
34}

Callers 3

hashFilesMethod · 0.90

Calls 2

updateMethod · 0.65
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…