UNPKG

902 BJavaScriptView 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 extraPaths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
20 var files = klawSync(pathModule.resolve(dirPath), {
21 nodir: true
22 }).map(function (f) {
23 return f.path;
24 });
25 var extraFiles = extraPaths.map(function (p) {
26 return pathModule.resolve(p);
27 });
28 files = files.concat(extraFiles);
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