MCPcopy Create free account
hub / github.com/vercel/vercel / hashFile

Function hashFile

packages/python-analysis/src/manifest/dist-metadata.ts:222–236  ·  view source on GitHub ↗

Stream a file through sha256 and return the base64url digest + byte size.

(filePath: string)

Source from the content-addressed store, hash-verified

220
221/** Stream a file through sha256 and return the base64url digest + byte size. */
222function hashFile(filePath: string): Promise<{ hash: string; size: number }> {
223 return new Promise((resolve, reject) => {
224 const h = createHash('sha256');
225 let size = 0;
226 const stream = createReadStream(filePath);
227 stream.on('data', (chunk: Uint8Array) => {
228 size += chunk.length;
229 h.update(chunk);
230 });
231 stream.on('error', reject);
232 stream.on('end', () => {
233 resolve({ hash: h.digest('base64url'), size });
234 });
235 });
236}
237
238/**
239 * Append new file entries to a distribution's RECORD file.

Callers 1

extendDistRecordFunction · 0.70

Calls 2

resolveFunction · 0.50
updateMethod · 0.45

Tested by

no test coverage detected