Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'config/helpers')
-rw-r--r--config/helpers/vendor_dll_hash.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/config/helpers/vendor_dll_hash.js b/config/helpers/vendor_dll_hash.js
new file mode 100644
index 00000000000..cfd7be66ad3
--- /dev/null
+++ b/config/helpers/vendor_dll_hash.js
@@ -0,0 +1,23 @@
+const fs = require('fs');
+const path = require('path');
+const crypto = require('crypto');
+
+const CACHE_PATHS = [
+ './config/webpack.config.js',
+ './config/webpack.vendor.config.js',
+ './package.json',
+ './yarn.lock',
+];
+
+const resolvePath = file => path.resolve(__dirname, '../..', file);
+const readFile = file => fs.readFileSync(file);
+const fileHash = buffer =>
+ crypto
+ .createHash('md5')
+ .update(buffer)
+ .digest('hex');
+
+module.exports = () => {
+ const fileBuffers = CACHE_PATHS.map(resolvePath).map(readFile);
+ return fileHash(Buffer.concat(fileBuffers)).substr(0, 12);
+};