UNPKG

1.64 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.checkFileInArchive = void 0;
7
8function _bluebirdLst() {
9 const data = require("bluebird-lst");
10
11 _bluebirdLst = function () {
12 return data;
13 };
14
15 return data;
16}
17
18function _fs() {
19 const data = require("builder-util/out/fs");
20
21 _fs = function () {
22 return data;
23 };
24
25 return data;
26}
27
28function _asar() {
29 const data = require("./asar");
30
31 _asar = function () {
32 return data;
33 };
34
35 return data;
36}
37
38/** @internal */
39let checkFileInArchive = (() => {
40 var _ref = (0, _bluebirdLst().coroutine)(function* (asarFile, relativeFile, messagePrefix) {
41 function error(text) {
42 return new Error(`${messagePrefix} "${relativeFile}" in the "${asarFile}" ${text}`);
43 }
44
45 let fs;
46
47 try {
48 fs = yield (0, _asar().readAsar)(asarFile);
49 } catch (e) {
50 throw error(`is corrupted: ${e}`);
51 }
52
53 let stat;
54
55 try {
56 stat = fs.getFile(relativeFile);
57 } catch (e) {
58 const fileStat = yield (0, _fs().statOrNull)(asarFile);
59
60 if (fileStat == null) {
61 throw error(`does not exist. Seems like a wrong configuration.`);
62 } // asar throws error on access to undefined object (info.link)
63
64
65 stat = null;
66 }
67
68 if (stat == null) {
69 throw error(`does not exist. Seems like a wrong configuration.`);
70 }
71
72 if (stat.size === 0) {
73 throw error(`is corrupted: size 0`);
74 }
75 });
76
77 return function checkFileInArchive(_x, _x2, _x3) {
78 return _ref.apply(this, arguments);
79 };
80})(); exports.checkFileInArchive = checkFileInArchive;
81//# sourceMappingURL=asarFileChecker.js.map
\No newline at end of file