Skip to content

Commit

Permalink
feat(dmg): check appId, dmg.icon, dmg.contents.path
Browse files Browse the repository at this point in the history
Closes #821
  • Loading branch information
develar committed Oct 13, 2016
1 parent 2f1a6e7 commit 36ed865
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
15 changes: 11 additions & 4 deletions src/appInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,26 @@ export class AppInfo {
}

get id(): string {
const appId = this.devMetadata.build["app-bundle-id"]
let appId = this.devMetadata.build["app-bundle-id"]
if (appId != null) {
warn("app-bundle-id is deprecated, please use appId")
}

if (this.devMetadata.build.appId != null) {
return this.devMetadata.build.appId
appId = this.devMetadata.build.appId
}

if (appId == null) {
const generateDefaultAppId = () => {
return `com.electron.${this.metadata.name.toLowerCase()}`
}
return appId

if (appId === "your.id" || isEmptyOrSpaces(appId)) {
const incorrectAppId = appId
appId = generateDefaultAppId()
warn(`Do not use "${incorrectAppId}" as appId, "${appId}" will be used instead`)
}

return appId == null ? generateDefaultAppId() : appId
}

get name(): string {
Expand Down
25 changes: 22 additions & 3 deletions src/targets/dmg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { log, warn } from "../util/log"
import { Target, PlatformPackager } from "../platformPackager"
import { MacOptions, DmgOptions, DmgContent } from "../options/macOptions"
import { Promise as BluebirdPromise } from "bluebird"
import { debug, use, exec, statOrNull } from "../util/util"
import { debug, use, exec, statOrNull, isEmptyOrSpaces } from "../util/util"
import { copy, unlink, outputFile, remove } from "fs-extra-p"
import { executeFinally } from "../util/promise"

Expand Down Expand Up @@ -79,7 +79,17 @@ export class DmgTarget extends Target {
]
}

const location: DmgContent = contents.find(it => it.path == null && it.type !== "link")!
let location = contents.find(it => it.path == null && it.type !== "link")
if (location == null) {
location = contents.find(it => {
if (it.path != null && it.path.endsWith(".app") && it.type !== "link") {
warn(`Do not specify path for application: "${it.path}". Actual path to app will be used instead.`)
return true
}
return false
})!
}

const applicationsLocation: DmgContent = contents.find(it => it.type === "link" && (it.path === "/Applications" || it.path === "Applications"))!

const window = specification.window!
Expand Down Expand Up @@ -181,7 +191,12 @@ export class DmgTarget extends Target {
}

if (specification.title != null) {
warn("dmg.title is not supported, file issue if need")
if (specification.title === packager.appInfo.productName) {
warn(`Do not specify unnecessary dmg.title ("${specification.title}") — application name ("${packager.appInfo.productFilename}") is used by default`)
}
else {
warn("dmg.title is not supported, file issue if need")
}
}

if (!("icon" in specification)) {
Expand All @@ -190,6 +205,10 @@ export class DmgTarget extends Target {
})
}

if (specification.icon != null && isEmptyOrSpaces(specification.icon)) {
throw new Error("dmg.icon cannot be specified as empty string")
}

if (specification["background-color"] != null) {
if (specification.backgroundColor == null) {
specification.backgroundColor = specification["background-color"]
Expand Down

0 comments on commit 36ed865

Please sign in to comment.