chore: cleanup files and split into modules
This commit is contained in:
13
src/sha.ts
Normal file
13
src/sha.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import * as fs from 'fs-extra';
|
||||
import * as crypto from 'crypto';
|
||||
|
||||
export const sha = async (filePath: string) => {
|
||||
const hash = crypto.createHash('sha256');
|
||||
const fileStream = fs.createReadStream(filePath);
|
||||
fileStream.pipe(hash);
|
||||
await new Promise((resolve, reject) => {
|
||||
fileStream.on('end', () => resolve());
|
||||
fileStream.on('error', (err) => reject(err));
|
||||
});
|
||||
return hash.digest('hex');
|
||||
};
|
||||
Reference in New Issue
Block a user