Skip to content

Commit

Permalink
feat(mac): rename electron.icns to productName.icns
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Aug 29, 2016
1 parent f8840e1 commit 8fa482e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
1 change: 1 addition & 0 deletions .idea/dictionaries/develar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions src/packager/mac.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ElectronPackagerOptions } from "./dirPackager"
import { rename, readFile, writeFile, copy } from "fs-extra-p"
import { rename, readFile, writeFile, copy, unlink } from "fs-extra-p"
import * as path from "path"
import { parse as parsePlist, build as buildPlist } from "plist"
import { Promise as BluebirdPromise } from "bluebird"
Expand Down Expand Up @@ -58,6 +58,13 @@ export async function createApp(opts: ElectronPackagerOptions, appOutDir: string
const appBundleIdentifier = filterCFBundleIdentifier(appInfo.id)
const helperBundleIdentifier = filterCFBundleIdentifier(opts["helper-bundle-id"] || `${appBundleIdentifier}.helper`)

const packager = opts.platformPackager
const icon = await packager.getIconPath()
const oldIcon = appPlist.CFBundleIconFile
if (icon != null) {
appPlist.CFBundleIconFile = `${appInfo.productFilename}.icns`
}

appPlist.CFBundleDisplayName = appInfo.productName
appPlist.CFBundleIdentifier = appBundleIdentifier
appPlist.CFBundleName = appInfo.productName
Expand All @@ -81,7 +88,6 @@ export async function createApp(opts: ElectronPackagerOptions, appOutDir: string
})
use(appInfo.buildVersion, it => appPlist.CFBundleVersion = it)

const packager = opts.platformPackager
const protocols = asArray(packager.devMetadata.build.protocols).concat(asArray(packager.platformSpecificBuildOptions.protocols))
if (protocols.length > 0) {
appPlist.CFBundleURLTypes = protocols.map(protocol => {
Expand All @@ -102,7 +108,7 @@ export async function createApp(opts: ElectronPackagerOptions, appOutDir: string
CFBundleTypeExtensions: extensions,
CFBundleTypeName: fileAssociation.name,
CFBundleTypeRole: fileAssociation.role || "Editor",
CFBundleTypeIconFile: customIcon || "electron.icns"
CFBundleTypeIconFile: customIcon || appPlist.CFBundleIconFile
}
})
}
Expand All @@ -118,8 +124,8 @@ export async function createApp(opts: ElectronPackagerOptions, appOutDir: string
doRename(path.join(contentsPath, "MacOS"), "Electron", appPlist.CFBundleExecutable)
]

const icon = await packager.getIconPath()
if (icon != null) {
promises.push(unlink(path.join(contentsPath, "Resources", oldIcon)))
promises.push(copy(icon, path.join(contentsPath, "Resources", appPlist.CFBundleIconFile)))
}

Expand Down
10 changes: 7 additions & 3 deletions src/util/tmp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ export class TmpDir {
removeSync(dir)
}
catch (e) {
warn(`Cannot delete temporary dir "${dir}": ${(e.stack || e).toString()}`)
if (e.code !== "EPERM") {
warn(`Cannot delete temporary dir "${dir}": ${(e.stack || e).toString()}`)
}
}
})
return dir
})
}

return this.tempDirectoryPromise
.then(it => path.join(it, `${(this.tmpFileCounter++).toString(16)}${suffix.startsWith(".") ? suffix : `-${suffix}`}`))
.then(it => path.join(it, `temp-${(this.tmpFileCounter++).toString(16)}${suffix.startsWith(".") ? suffix : `-${suffix}`}`))
}

cleanup(): Promise<any> {
Expand All @@ -61,7 +63,9 @@ export class TmpDir {
this.dir = null
})
.catch(e => {
warn(`Cannot delete temporary dir "${this.dir}": ${(e.stack || e).toString()}`)
if (e.code !== "EPERM") {
warn(`Cannot delete temporary dir "${this.dir}": ${(e.stack || e).toString()}`)
}
})
}
}
7 changes: 5 additions & 2 deletions src/windowsCodeSign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { getBinFromBintray } from "./util/binDownload"
//noinspection JSUnusedLocalSymbols
const __awaiter = require("./util/awaiter")

const TOOLS_VERSION = "1.4.1"
const TOOLS_VERSION = "1.4.2"

export function getSignVendorPath() {
return getBinFromBintray("winCodeSign", TOOLS_VERSION, "bcafcb1aa9be7544ca9bdffda277e4dcf840f14964e51ed270f83fb850cf2e9e")
return getBinFromBintray("winCodeSign", TOOLS_VERSION, "ca94097071ce6433a2e18a14518b905ac162afaef82ed88713a8a91c32a55b21")
}

export interface SignOptions {
Expand Down Expand Up @@ -147,6 +147,9 @@ async function getToolPath() {
if (process.platform === "win32") {
return path.join(vendorPath, `windows-${(release().startsWith("6.") ? "6" : "10")}`, "signtool.exe")
}
else if (process.platform === "darwin" && process.env.CI) {
return path.join(vendorPath, process.platform, "ci", "osslsigncode")
}
else {
return path.join(vendorPath, process.platform, "osslsigncode")
}
Expand Down

0 comments on commit 8fa482e

Please sign in to comment.