-
-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathafterPackArm64.js
More file actions
60 lines (56 loc) · 1.7 KB
/
Copy pathafterPackArm64.js
File metadata and controls
60 lines (56 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const fs = require("fs");
const path = require("path");
const archiver = require("archiver");
exports.default = async function (buildResult) {
const version = require("./package.json").version;
const artifacts = [
{
source: path.join(
buildResult.outDir,
`elecap-${version}-win-arm64-portable.exe`,
),
destination: path.join(
buildResult.outDir,
`elecap_win_v${version}_arm64_portable.zip`,
),
},
{
source: path.join(
buildResult.outDir,
`elecap-${version}-win-arm64-setup.exe`,
),
destination: path.join(
buildResult.outDir,
`elecap_win_v${version}_arm64_installer.zip`,
),
},
];
// `electron-builder --dir` intentionally creates no installer artifacts.
// Keep that mode available for local packaging and architecture checks.
if (artifacts.every((artifact) => !fs.existsSync(artifact.source))) {
return [];
}
const createdArtifacts = [];
for (const artifact of artifacts) {
if (!fs.existsSync(artifact.source)) {
throw new Error(
`Expected Windows ARM64 artifact not found: ${artifact.source}`,
);
}
await createZip(artifact.source, artifact.destination);
createdArtifacts.push(artifact.destination);
}
return createdArtifacts;
};
function createZip(source, destination) {
return new Promise((resolve, reject) => {
const output = fs.createWriteStream(destination);
const archive = archiver("zip", { zlib: { level: 9 } });
output.on("close", resolve);
output.on("error", reject);
archive.on("error", reject);
archive.pipe(output);
archive.file(source, { name: path.basename(source) });
archive.finalize();
});
}