debian-mirror-gitlab/config/helpers/vendor_dll_hash.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
598 B
JavaScript
Raw Normal View History

2021-06-08 01:23:25 +05:30
const fs = require('fs');
2021-04-17 20:07:23 +05:30
const path = require('path');
2022-03-02 08:16:31 +05:30
const crypto = require('./patched_crypto');
2020-01-01 13:55:28 +05:30
const CACHE_PATHS = [
'./config/webpack.config.js',
'./config/webpack.vendor.config.js',
'./package.json',
'./yarn.lock',
];
2021-03-08 18:12:59 +05:30
const resolvePath = (file) => path.resolve(__dirname, '../..', file);
const readFile = (file) => fs.readFileSync(file);
2022-03-02 08:16:31 +05:30
const fileHash = (buffer) => crypto.createHash('sha256').update(buffer).digest('hex');
2020-01-01 13:55:28 +05:30
module.exports = () => {
const fileBuffers = CACHE_PATHS.map(resolvePath).map(readFile);
return fileHash(Buffer.concat(fileBuffers)).substr(0, 12);
};