mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-05-05 02:59:31 +08:00
24 lines
598 B
Text
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 : ''}'`,
|
|
);
|
|
}
|
|
}
|