Skip to content

Commit 3e2798f

Browse files
committed
fix: directories.output is ignored when building .dmg for a prepackaged app
Close #1308
1 parent d493ade commit 3e2798f

File tree

6 files changed

+9
-8
lines changed

6 files changed

+9
-8
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ A complete solution to package and build a ready for distribution Electron app f
66
* Development dependencies are never included. You don't need to ignore them explicitly.
77
* [Code Signing](https://github.com/electron-userland/electron-builder/wiki/Code-Signing) on a CI server or development machine.
88
* [Auto Update](https://github.com/electron-userland/electron-builder/wiki/Auto-Update) ready application packaging.
9-
* [Build version management](https://github.com/electron-userland/electron-builder/wiki/Options#build-version-management).
109
* Numerous target formats:
1110
* All platforms: `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir` (unpacked directory).
1211
* [macOS](https://github.com/electron-userland/electron-builder/wiki/Options#MacOptions-target): `dmg`, `pkg`, `mas`.
1312
* [Linux](https://github.com/electron-userland/electron-builder/wiki/Options#LinuxBuildOptions-target): [AppImage](http://appimage.org), [snap](http://snapcraft.io), debian package (`deb`), `rpm`, `freebsd`, `pacman`, `p5p`, `apk`.
1413
* [Windows](https://github.com/electron-userland/electron-builder/wiki/Options#WinBuildOptions-target): `nsis` (Installer), `nsis-web` (Web installer), `portable` (portable app without installation), AppX (Windows Store), Squirrel.Windows.
1514
* [Two package.json structure](https://github.com/electron-userland/electron-builder/wiki/Two-package.json-Structure) is supported, but you are not forced to use it even if you have native production dependencies.
15+
* [Build version management](https://github.com/electron-userland/electron-builder/wiki/Options#build-version-management).
1616
* [Publishing artifacts](https://github.com/electron-userland/electron-builder/wiki/Publishing-Artifacts) to GitHub Releases, Amazon S3 and Bintray.
1717
* Pack in a distributable format [already packaged app](#pack-only-in-a-distributable-format).
1818
* Separate [build steps](https://github.com/electron-userland/electron-builder/issues/1102#issuecomment-271845854).
19+
* Build and publish in parallel, using hard links on CI server to reduce IO and disk space usage.
1920

2021
| Question | Answer |
2122
|--------|-------|

packages/electron-builder/src/macPackager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ export default class MacPackager extends PlatformPackager<MacOptions> {
5151
break
5252

5353
case "dmg":
54-
mapper("dmg", outDir => new DmgTarget(this, outDir))
54+
mapper("dmg", outDir => new DmgTarget(this, path.join(outDir, "mac")))
5555
break
5656

5757
case "pkg":
58-
mapper("pkg", outDir => new PkgTarget(this, outDir))
58+
mapper("pkg", outDir => new PkgTarget(this, path.join(outDir, "mac")))
5959
break
6060

6161
default:
62-
mapper(name, outDir => name === "mas" || name === "mas-dev" ? new NoOpTarget(name) : createCommonTarget(name, outDir, this))
62+
mapper(name, outDir => name === "mas" || name === "mas-dev" ? new NoOpTarget(name) : createCommonTarget(name, path.join(outDir, "mac"), this))
6363
break
6464
}
6565
}

packages/electron-builder/src/targets/ArchiveTarget.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class ArchiveTarget extends Target {
2121
const outFile = (() => {
2222
switch (packager.platform) {
2323
case Platform.MAC:
24-
return path.join(path.dirname(appOutDir), packager.generateName2(format, "mac", false))
24+
return path.join(outDir, packager.generateName2(format, "mac", false))
2525
case Platform.WINDOWS:
2626
return path.join(outDir, packager.generateName(format, arch, false, "win"))
2727
case Platform.LINUX:

packages/electron-builder/src/targets/dmg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export class DmgTarget extends Target {
160160
}
161161
})
162162

163-
const artifactPath = path.join(path.dirname(appPath), packager.expandArtifactNamePattern(packager.config.dmg, "dmg"))
163+
const artifactPath = path.join(this.outDir, packager.expandArtifactNamePattern(packager.config.dmg, "dmg"))
164164
//noinspection SpellCheckingInspection
165165
await spawn("hdiutil", addVerboseIfNeed(["convert", tempDmg, "-format", packager.config.compression === "store" ? "UDRO" : "UDBZ", "-imagekey", "zlib-level=9", "-o", artifactPath]))
166166
await exec("hdiutil", addVerboseIfNeed(["internet-enable", "-no"]).concat(artifactPath))

packages/electron-builder/src/targets/pkg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class PkgTarget extends Target {
3030
throw new Error(`Cannot find valid "${certType}" to sign standalone installer, please see https://github.com/electron-userland/electron-builder/wiki/Code-Signing`)
3131
}
3232

33-
const appOutDir = path.dirname(appPath)
33+
const appOutDir = this.outDir
3434
const distInfo = path.join(appOutDir, "distribution.xml")
3535
await exec("productbuild", ["--synthesize", "--component", appPath, this.installLocation, distInfo], {
3636
cwd: appOutDir,

test/src/mac/macPackagerTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ test.ifMac("one-package", app({
6262
await assertThat(path.join(appDir, "Contents", "Resources", "someFoo.icns")).isFile()
6363
},
6464
packed: async context => {
65-
expect(convertUpdateInfo(await readJson(path.join(context.outDir, "latest-mac.json")))).toMatchSnapshot()
65+
expect(convertUpdateInfo(await readJson(path.join(context.outDir, "mac", "latest-mac.json")))).toMatchSnapshot()
6666
},
6767
}))
6868

0 commit comments

Comments
 (0)