chore: cleanup files and split into modules

This commit is contained in:
Samuel Attard
2020-11-19 09:49:17 -08:00
parent c01deb5576
commit 0770238718
5 changed files with 186 additions and 98 deletions

13
src/sha.ts Normal file
View 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');
};