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 | const fs = require('fs');
|
10 |
|
11 | const getStringHash = require('./get-string-hash');
|
12 | const errors = require('./errors');
|
13 |
|
14 | module.exports = (file) => {
|
15 | try {
|
16 | const buffer = fs.readFileSync(file);
|
17 | return getStringHash(buffer);
|
18 | } catch (err) {
|
19 | throw new Error(errors['unable-to-get-file-hash'] + ` '${err.message}'`);
|
20 | }
|
21 | };
|