Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
477a52e779 |
@@ -5,11 +5,12 @@ import { d } from './debug';
|
|||||||
export const sha = async (filePath: string) => {
|
export const sha = async (filePath: string) => {
|
||||||
d('hashing', filePath);
|
d('hashing', filePath);
|
||||||
const hash = crypto.createHash('sha256');
|
const hash = crypto.createHash('sha256');
|
||||||
|
hash.setEncoding('hex');
|
||||||
const fileStream = fs.createReadStream(filePath);
|
const fileStream = fs.createReadStream(filePath);
|
||||||
fileStream.pipe(hash);
|
fileStream.pipe(hash);
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
fileStream.on('end', () => resolve());
|
fileStream.on('end', () => resolve());
|
||||||
fileStream.on('error', (err) => reject(err));
|
fileStream.on('error', (err) => reject(err));
|
||||||
});
|
});
|
||||||
return hash.digest('hex');
|
return hash.read();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user