UNPKG

1.13 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8var pathModule = require('path');
9
10var fs = require('fs'); // flow-disable-next-line
11
12
13var klawSync = require('klaw-sync'); // flow-disable-next-line
14
15
16var md5 = require('md5');
17
18var dirChecksum = function dirChecksum(dirPath) {
19 var basePath = pathModule.resolve(dirPath);
20 var files = klawSync(dirPath, {
21 nodir: true,
22 filter: function filter(_ref) {
23 var path = _ref.path;
24 return !RegExp("^".concat(basePath, "/node_modules/")).test(path) && !RegExp("^".concat(basePath, "/dist/")).test(path) && !RegExp("^".concat(basePath, "/.git/")).test(path) && !RegExp("^".concat(basePath, "/coverage/")).test(path) && !RegExp("^".concat(basePath, "/lib/")).test(path) && !RegExp("^".concat(basePath, "/data/")).test(path);
25 }
26 }).map(function (f) {
27 return f.path;
28 });
29 var md5s = files.map(function (f) {
30 return fs.readFileSync(f);
31 });
32 var concatenatedMd5s = md5s.join();
33 var finalMd5 = md5(concatenatedMd5s);
34 return finalMd5;
35};
36
37var _default = dirChecksum;
38exports.default = _default;
\No newline at end of file