UNPKG

1.2 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.checkFileInArchive = void 0;
4const fs_1 = require("builder-util/out/fs");
5const asar_1 = require("./asar");
6/** @internal */
7async function checkFileInArchive(asarFile, relativeFile, messagePrefix) {
8 function error(text) {
9 return new Error(`${messagePrefix} "${relativeFile}" in the "${asarFile}" ${text}`);
10 }
11 let fs;
12 try {
13 fs = await (0, asar_1.readAsar)(asarFile);
14 }
15 catch (e) {
16 throw error(`is corrupted: ${e}`);
17 }
18 let stat;
19 try {
20 stat = fs.getFile(relativeFile);
21 }
22 catch (e) {
23 const fileStat = await (0, fs_1.statOrNull)(asarFile);
24 if (fileStat == null) {
25 throw error(`does not exist. Seems like a wrong configuration.`);
26 }
27 // asar throws error on access to undefined object (info.link)
28 stat = null;
29 }
30 if (stat == null) {
31 throw error(`does not exist. Seems like a wrong configuration.`);
32 }
33 if (stat.size === 0) {
34 throw error(`is corrupted: size 0`);
35 }
36}
37exports.checkFileInArchive = checkFileInArchive;
38//# sourceMappingURL=asarFileChecker.js.map
\No newline at end of file