feat: add deterministic cleared project media
This commit is contained in:
10
scripts/lib/hash-file.mjs
Normal file
10
scripts/lib/hash-file.mjs
Normal file
@@ -0,0 +1,10 @@
|
||||
import { createHash } from 'node:crypto';
|
||||
import { createReadStream } from 'node:fs';
|
||||
|
||||
export const hashFile = async (path) => new Promise((resolve, reject) => {
|
||||
const digest = createHash('sha256');
|
||||
const stream = createReadStream(path);
|
||||
stream.on('error', reject);
|
||||
stream.on('data', (chunk) => digest.update(chunk));
|
||||
stream.on('end', () => resolve(digest.digest('hex')));
|
||||
});
|
||||
Reference in New Issue
Block a user