|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
598 bytes
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | Copyright 2018 Google LLC
|
|---|
| 3 |
|
|---|
| 4 | Use of this source code is governed by an MIT-style
|
|---|
| 5 | license that can be found in the LICENSE file or at
|
|---|
| 6 | https://opensource.org/licenses/MIT.
|
|---|
| 7 | */
|
|---|
| 8 |
|
|---|
| 9 | import fse from 'fs-extra';
|
|---|
| 10 |
|
|---|
| 11 | import {getStringHash} from './get-string-hash';
|
|---|
| 12 | import {errors} from './errors';
|
|---|
| 13 |
|
|---|
| 14 | export function getFileHash(file: string): string {
|
|---|
| 15 | try {
|
|---|
| 16 | const buffer = fse.readFileSync(file);
|
|---|
| 17 | return getStringHash(buffer);
|
|---|
| 18 | } catch (err) {
|
|---|
| 19 | throw new Error(
|
|---|
| 20 | errors['unable-to-get-file-hash'] +
|
|---|
| 21 | ` '${err instanceof Error && err.message ? err.message : ''}'`,
|
|---|
| 22 | );
|
|---|
| 23 | }
|
|---|
| 24 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.