2019-12-17 04:07:48 -05:00
|
|
|
const crypto = require('crypto');
|
2021-05-14 11:10:35 -04:00
|
|
|
const fs = require('fs');
|
2021-03-10 10:09:11 -05:00
|
|
|
const path = require('path');
|
2019-12-17 04:07:48 -05:00
|
|
|
|
|
|
|
const CACHE_PATHS = [
|
|
|
|
'./config/webpack.config.js',
|
|
|
|
'./config/webpack.vendor.config.js',
|
|
|
|
'./package.json',
|
|
|
|
'./yarn.lock',
|
|
|
|
];
|
|
|
|
|
2020-12-23 16:10:24 -05:00
|
|
|
const resolvePath = (file) => path.resolve(__dirname, '../..', file);
|
|
|
|
const readFile = (file) => fs.readFileSync(file);
|
|
|
|
const fileHash = (buffer) => crypto.createHash('md5').update(buffer).digest('hex');
|
2019-12-17 04:07:48 -05:00
|
|
|
|
|
|
|
module.exports = () => {
|
|
|
|
const fileBuffers = CACHE_PATHS.map(resolvePath).map(readFile);
|
|
|
|
return fileHash(Buffer.concat(fileBuffers)).substr(0, 12);
|
|
|
|
};
|