UNPKG

2.08 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.getWindowsInstallationAppPackageName = exports.getWindowsInstallationDirName = exports.createStageDirPath = exports.createStageDir = exports.StageDir = void 0;
4const path = require("path");
5const builder_util_1 = require("builder-util");
6const fs = require("fs/promises");
7class 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}
24exports.StageDir = StageDir;
25async function createStageDir(target, packager, arch) {
26 return new StageDir(await createStageDirPath(target, packager, arch));
27}
28exports.createStageDir = createStageDir;
29async 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}
35exports.createStageDirPath = createStageDirPath;
36// https://github.com/electron-userland/electron-builder/issues/3100
37// https://github.com/electron-userland/electron-builder/commit/2539cfba20dc639128e75c5b786651b652bb4b78
38function getWindowsInstallationDirName(appInfo, isTryToUseProductName) {
39 return isTryToUseProductName && /^[-_+0-9a-zA-Z .]+$/.test(appInfo.productFilename) ? appInfo.productFilename : appInfo.sanitizedName;
40}
41exports.getWindowsInstallationDirName = getWindowsInstallationDirName;
42// https://github.com/electron-userland/electron-builder/issues/6747
43function getWindowsInstallationAppPackageName(appName) {
44 return appName.replace(/\//g, "\\");
45}
46exports.getWindowsInstallationAppPackageName = getWindowsInstallationAppPackageName;
47//# sourceMappingURL=targetUtil.js.map
\No newline at end of file