Skip to content

Commit

Permalink
fix: directories.output is ignored when building .dmg for a prepackag…
Browse files Browse the repository at this point in the history
…ed app

Close #1308
  • Loading branch information
develar committed Feb 27, 2017
1 parent d493ade commit 3e2798f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ A complete solution to package and build a ready for distribution Electron app f
* Development dependencies are never included. You don't need to ignore them explicitly.
* [Code Signing](https://github.com/electron-userland/electron-builder/wiki/Code-Signing) on a CI server or development machine.
* [Auto Update](https://github.com/electron-userland/electron-builder/wiki/Auto-Update) ready application packaging.
* [Build version management](https://github.com/electron-userland/electron-builder/wiki/Options#build-version-management).
* Numerous target formats:
* All platforms: `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir` (unpacked directory).
* [macOS](https://github.com/electron-userland/electron-builder/wiki/Options#MacOptions-target): `dmg`, `pkg`, `mas`.
* [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`.
* [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.
* [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.
* [Build version management](https://github.com/electron-userland/electron-builder/wiki/Options#build-version-management).
* [Publishing artifacts](https://github.com/electron-userland/electron-builder/wiki/Publishing-Artifacts) to GitHub Releases, Amazon S3 and Bintray.
* Pack in a distributable format [already packaged app](#pack-only-in-a-distributable-format).
* Separate [build steps](https://github.com/electron-userland/electron-builder/issues/1102#issuecomment-271845854).
* Build and publish in parallel, using hard links on CI server to reduce IO and disk space usage.

| Question | Answer |
|--------|-------|
Expand Down
6 changes: 3 additions & 3 deletions packages/electron-builder/src/macPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ export default class MacPackager extends PlatformPackager<MacOptions> {
break

case "dmg":
mapper("dmg", outDir => new DmgTarget(this, outDir))
mapper("dmg", outDir => new DmgTarget(this, path.join(outDir, "mac")))
break

case "pkg":
mapper("pkg", outDir => new PkgTarget(this, outDir))
mapper("pkg", outDir => new PkgTarget(this, path.join(outDir, "mac")))
break

default:
mapper(name, outDir => name === "mas" || name === "mas-dev" ? new NoOpTarget(name) : createCommonTarget(name, outDir, this))
mapper(name, outDir => name === "mas" || name === "mas-dev" ? new NoOpTarget(name) : createCommonTarget(name, path.join(outDir, "mac"), this))
break
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/src/targets/ArchiveTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class ArchiveTarget extends Target {
const outFile = (() => {
switch (packager.platform) {
case Platform.MAC:
return path.join(path.dirname(appOutDir), packager.generateName2(format, "mac", false))
return path.join(outDir, packager.generateName2(format, "mac", false))
case Platform.WINDOWS:
return path.join(outDir, packager.generateName(format, arch, false, "win"))
case Platform.LINUX:
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/src/targets/dmg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class DmgTarget extends Target {
}
})

const artifactPath = path.join(path.dirname(appPath), packager.expandArtifactNamePattern(packager.config.dmg, "dmg"))
const artifactPath = path.join(this.outDir, packager.expandArtifactNamePattern(packager.config.dmg, "dmg"))
//noinspection SpellCheckingInspection
await spawn("hdiutil", addVerboseIfNeed(["convert", tempDmg, "-format", packager.config.compression === "store" ? "UDRO" : "UDBZ", "-imagekey", "zlib-level=9", "-o", artifactPath]))
await exec("hdiutil", addVerboseIfNeed(["internet-enable", "-no"]).concat(artifactPath))
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/src/targets/pkg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class PkgTarget extends Target {
throw new Error(`Cannot find valid "${certType}" to sign standalone installer, please see https://github.com/electron-userland/electron-builder/wiki/Code-Signing`)
}

const appOutDir = path.dirname(appPath)
const appOutDir = this.outDir
const distInfo = path.join(appOutDir, "distribution.xml")
await exec("productbuild", ["--synthesize", "--component", appPath, this.installLocation, distInfo], {
cwd: appOutDir,
Expand Down
2 changes: 1 addition & 1 deletion test/src/mac/macPackagerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ test.ifMac("one-package", app({
await assertThat(path.join(appDir, "Contents", "Resources", "someFoo.icns")).isFile()
},
packed: async context => {
expect(convertUpdateInfo(await readJson(path.join(context.outDir, "latest-mac.json")))).toMatchSnapshot()
expect(convertUpdateInfo(await readJson(path.join(context.outDir, "mac", "latest-mac.json")))).toMatchSnapshot()
},
}))

Expand Down

0 comments on commit 3e2798f

Please sign in to comment.