1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.getWindowsInstallationAppPackageName = exports.getWindowsInstallationDirName = exports.createStageDirPath = exports.createStageDir = exports.StageDir = void 0;
|
4 | const path = require("path");
|
5 | const builder_util_1 = require("builder-util");
|
6 | const fs = require("fs/promises");
|
7 | class StageDir {
|
8 | constructor(dir) {
|
9 | this.dir = dir;
|
10 | }
|
11 | getTempFile(name) {
|
12 | return this.dir + path.sep + name;
|
13 | }
|
14 | cleanup() {
|
15 | if (!builder_util_1.debug.enabled || process.env.ELECTRON_BUILDER_REMOVE_STAGE_EVEN_IF_DEBUG === "true") {
|
16 | return fs.rm(this.dir, { recursive: true, force: true });
|
17 | }
|
18 | return Promise.resolve();
|
19 | }
|
20 | toString() {
|
21 | return this.dir;
|
22 | }
|
23 | }
|
24 | exports.StageDir = StageDir;
|
25 | async function createStageDir(target, packager, arch) {
|
26 | return new StageDir(await createStageDirPath(target, packager, arch));
|
27 | }
|
28 | exports.createStageDir = createStageDir;
|
29 | async function createStageDirPath(target, packager, arch) {
|
30 | const tempDir = packager.info.stageDirPathCustomizer(target, packager, arch);
|
31 | await fs.rm(tempDir, { recursive: true, force: true });
|
32 | await fs.mkdir(tempDir, { recursive: true });
|
33 | return tempDir;
|
34 | }
|
35 | exports.createStageDirPath = createStageDirPath;
|
36 |
|
37 |
|
38 | function getWindowsInstallationDirName(appInfo, isTryToUseProductName) {
|
39 | return isTryToUseProductName && /^[-_+0-9a-zA-Z .]+$/.test(appInfo.productFilename) ? appInfo.productFilename : appInfo.sanitizedName;
|
40 | }
|
41 | exports.getWindowsInstallationDirName = getWindowsInstallationDirName;
|
42 |
|
43 | function getWindowsInstallationAppPackageName(appName) {
|
44 | return appName.replace(/\//g, "\\");
|
45 | }
|
46 | exports.getWindowsInstallationAppPackageName = getWindowsInstallationAppPackageName;
|
47 |
|
\ | No newline at end of file |