UNPKG

3.29 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.ArchiveTarget = 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 _builderUtil() {
19 const data = require("builder-util");
20
21 _builderUtil = function () {
22 return data;
23 };
24
25 return data;
26}
27
28var path = _interopRequireWildcard(require("path"));
29
30function _core() {
31 const data = require("../core");
32
33 _core = function () {
34 return data;
35 };
36
37 return data;
38}
39
40function _archive() {
41 const data = require("./archive");
42
43 _archive = function () {
44 return data;
45 };
46
47 return data;
48}
49
50function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
51
52class ArchiveTarget extends _core().Target {
53 constructor(name, outDir, packager, isWriteUpdateInfo = false) {
54 super(name);
55 this.outDir = outDir;
56 this.packager = packager;
57 this.isWriteUpdateInfo = isWriteUpdateInfo;
58 this.options = this.packager.config[this.name];
59 }
60
61 build(appOutDir, arch) {
62 var _this = this;
63
64 return (0, _bluebirdLst().coroutine)(function* () {
65 const packager = _this.packager;
66
67 const isMac = packager.platform === _core().Platform.MAC;
68
69 const format = _this.name;
70 let defaultPattern;
71
72 if (packager.platform === _core().Platform.LINUX) {
73 // tslint:disable-next-line:no-invalid-template-strings
74 defaultPattern = "${name}-${version}" + (arch === _builderUtil().Arch.x64 ? "" : "-${arch}") + ".${ext}";
75 } else {
76 // tslint:disable-next-line:no-invalid-template-strings
77 defaultPattern = "${productName}-${version}" + (arch === _builderUtil().Arch.x64 ? "" : "-${arch}") + "-${os}.${ext}";
78 }
79
80 const artifactName = packager.expandArtifactNamePattern(_this.options, format, arch, defaultPattern, false);
81 const artifactPath = path.join(_this.outDir, artifactName);
82
83 _this.logBuilding(`${isMac ? "macOS " : ""}${format}`, artifactPath, arch);
84
85 if (format.startsWith("tar.")) {
86 yield (0, _archive().tar)(packager.compression, format, artifactPath, appOutDir, isMac, packager.info.tempDirManager);
87 } else {
88 yield (0, _archive().archive)(format, artifactPath, appOutDir, {
89 compression: packager.compression,
90 withoutDir: !isMac
91 });
92 }
93
94 packager.info.dispatchArtifactCreated({
95 file: artifactPath,
96 // tslint:disable-next-line:no-invalid-template-strings
97 safeArtifactName: packager.computeSafeArtifactName(artifactName, format, arch, false, defaultPattern.replace("${productName}", "${name}")),
98 target: _this,
99 arch,
100 packager,
101 isWriteUpdateInfo: _this.isWriteUpdateInfo
102 });
103 })();
104 }
105
106} exports.ArchiveTarget = ArchiveTarget;
107//# sourceMappingURL=ArchiveTarget.js.map
\No newline at end of file