1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.computeData = undefined;
|
7 |
|
8 | var _bluebirdLst;
|
9 |
|
10 | function _load_bluebirdLst() {
|
11 | return _bluebirdLst = require("bluebird-lst");
|
12 | }
|
13 |
|
14 | var _bluebirdLst2;
|
15 |
|
16 | function _load_bluebirdLst2() {
|
17 | return _bluebirdLst2 = _interopRequireDefault(require("bluebird-lst"));
|
18 | }
|
19 |
|
20 | let computeData = exports.computeData = (() => {
|
21 | var _ref = (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* (resourcesPath, options) {
|
22 |
|
23 | const names = (yield (0, (_fsExtraP || _load_fsExtraP()).readdir)(resourcesPath)).filter(function (it) {
|
24 | return it.endsWith(".asar");
|
25 | }).sort();
|
26 | const checksums = yield (_bluebirdLst2 || _load_bluebirdLst2()).default.map(names, function (it) {
|
27 | return hashFile(_path.join(resourcesPath, it));
|
28 | });
|
29 | const result = {};
|
30 | for (let i = 0; i < names.length; i++) {
|
31 | result[names[i]] = checksums[i];
|
32 | }
|
33 | return Object.assign({ checksums: result }, options);
|
34 | });
|
35 |
|
36 | return function computeData(_x, _x2) {
|
37 | return _ref.apply(this, arguments);
|
38 | };
|
39 | })();
|
40 |
|
41 | var _crypto;
|
42 |
|
43 | function _load_crypto() {
|
44 | return _crypto = require("crypto");
|
45 | }
|
46 |
|
47 | var _fs;
|
48 |
|
49 | function _load_fs() {
|
50 | return _fs = require("fs");
|
51 | }
|
52 |
|
53 | var _fsExtraP;
|
54 |
|
55 | function _load_fsExtraP() {
|
56 | return _fsExtraP = require("fs-extra-p");
|
57 | }
|
58 |
|
59 | var _path = _interopRequireWildcard(require("path"));
|
60 |
|
61 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
62 |
|
63 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
64 |
|
65 | function hashFile(file, algorithm = "sha512", encoding = "base64") {
|
66 | return new (_bluebirdLst2 || _load_bluebirdLst2()).default((resolve, reject) => {
|
67 | const hash = (0, (_crypto || _load_crypto()).createHash)(algorithm);
|
68 | hash.on("error", reject).setEncoding(encoding);
|
69 | (0, (_fs || _load_fs()).createReadStream)(file).on("error", reject).on("end", () => {
|
70 | hash.end();
|
71 | resolve(hash.read());
|
72 | }).pipe(hash, { end: false });
|
73 | });
|
74 | }
|
75 |
|
\ | No newline at end of file |