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

20 lines
585 B
JavaScript
Raw Normal View History

2020-01-01 13:55:28 +05:30
const crypto = require('crypto');
2021-06-08 01:23:25 +05:30
const fs = require('fs');
2021-04-17 20:07:23 +05:30
const path = require('path');
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);
const fileHash = (buffer) => crypto.createHash('md5').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);
};