Urara-Blog/node_modules/.pnpm-store/v3/files/24/217e02fc3f1a8972883dff7c426688cc0afea104a87ba54df04e89ea645862c884fccda1c14c840436dfe63ed6c5d6c5294152217c5fc74c2de12ee3b7ca02
2022-08-14 01:14:53 +08:00

24 lines
598 B
Text

/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
import fse from 'fs-extra';
import {getStringHash} from './get-string-hash';
import {errors} from './errors';
export function getFileHash(file: string): string {
try {
const buffer = fse.readFileSync(file);
return getStringHash(buffer);
} catch (err) {
throw new Error(
errors['unable-to-get-file-hash'] +
` '${err instanceof Error && err.message ? err.message : ''}'`,
);
}
}