Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure that CFBundleExecutable and friends are correct for helper apps #1046

Merged
merged 2 commits into from Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 19 additions & 10 deletions src/mac.js
Expand Up @@ -110,11 +110,15 @@ class MacApp extends App {
})
}

updateHelperPlist (base, suffix) {
updateHelperPlist (base, suffix, identifierIgnoresSuffix) {
let helperSuffix, identifier, name
if (suffix) {
helperSuffix = `Helper ${suffix}`
identifier = `${this.helperBundleIdentifier}.${suffix}`
if (identifierIgnoresSuffix) {
identifier = this.helperBundleIdentifier
} else {
identifier = `${this.helperBundleIdentifier}.${suffix}`
}
name = `${this.appName} ${helperSuffix}`
} else {
helperSuffix = 'Helper'
Expand Down Expand Up @@ -162,9 +166,9 @@ class MacApp extends App {
]

const possiblePlists = [
[this.ehPlistFilename('Electron Helper (Renderer).app'), 'helperPlist'],
[this.ehPlistFilename('Electron Helper (Plugin).app'), 'helperPlist'],
[this.ehPlistFilename('Electron Helper (GPU).app'), 'helperPlist'],
[this.ehPlistFilename('Electron Helper (Renderer).app'), 'helperRendererPlist'],
[this.ehPlistFilename('Electron Helper (Plugin).app'), 'helperPluginPlist'],
[this.ehPlistFilename('Electron Helper (GPU).app'), 'helperGPUPlist'],
[this.ehPlistFilename('Electron Helper EH.app'), 'helperEHPlist'],
[this.ehPlistFilename('Electron Helper NP.app'), 'helperNPPlist'],
[this.helperPlistFilename(this.loginHelperPath), 'loginHelperPlist']
Expand All @@ -184,11 +188,16 @@ class MacApp extends App {
await this.extendAppPlist(this.opts.extendInfo)
this.appPlist = this.updatePlist(this.appPlist, this.executableName, appBundleIdentifier, this.appName)
this.helperPlist = this.updateHelperPlist(this.helperPlist)
if (this.helperEHPlist) {
this.helperEHPlist = this.updateHelperPlist(this.helperEHPlist, 'EH')
}
if (this.helperNPPlist) {
this.helperNPPlist = this.updateHelperPlist(this.helperNPPlist, 'NP')
const updateIfExists = [
['helperRendererPlist', '(Renderer)', true],
['helperPluginPlist', '(Plugin)', true],
['helperGPUPlist', '(GPU)', true],
['helperEHPlist', 'EH'],
['helperNPPlist', 'NP']
]
for (const [plistKey, ...suffixArgs] of updateIfExists) {
if (!this[plistKey]) continue
this[plistKey] = this.updateHelperPlist(this[plistKey], ...suffixArgs)
}

if (this.loginHelperPlist) {
Expand Down
9 changes: 6 additions & 3 deletions test/darwin.js
Expand Up @@ -182,15 +182,18 @@ async function appHelpersBundleElectron6Test (t, opts) {
assertCFBundleIdentifierValue(t, helperObj, helperBundleIdentifier, 'CFBundleIdentifier should reflect opts.helperBundleId, opts.appBundleId or fallback to default in helper app')

const helperPluginObj = await util.parsePlist(t, path.join(frameworksPath, `${opts.name} Helper (Plugin).app`))
assertPlistStringValue(t, helperPluginObj, 'CFBundleName', opts.name, 'CFBundleName should reflect opts.name in helper app')
assertPlistStringValue(t, helperPluginObj, 'CFBundleName', `${opts.name} Helper (Plugin)`, 'CFBundleName should reflect opts.name in helper app')
assertPlistStringValue(t, helperPluginObj, 'CFBundleExecutable', `${opts.name} Helper (Plugin)`, 'CFBundleExecutable should reflect opts.name in helper app')
assertCFBundleIdentifierValue(t, helperPluginObj, helperBundleIdentifier, 'CFBundleIdentifier should reflect opts.helperBundleId, opts.appBundleId or fallback to default in helper app')

const helperRendererObj = await util.parsePlist(t, path.join(frameworksPath, `${opts.name} Helper (Renderer).app`))
assertPlistStringValue(t, helperRendererObj, 'CFBundleName', opts.name, 'CFBundleName should reflect opts.name in helper app')
assertPlistStringValue(t, helperRendererObj, 'CFBundleName', `${opts.name} Helper (Renderer)`, 'CFBundleName should reflect opts.name in helper app')
assertPlistStringValue(t, helperRendererObj, 'CFBundleExecutable', `${opts.name} Helper (Renderer)`, 'CFBundleExecutable should reflect opts.name in helper app')
assertCFBundleIdentifierValue(t, helperRendererObj, helperBundleIdentifier, 'CFBundleIdentifier should reflect opts.helperBundleId, opts.appBundleId or fallback to default in helper app')

const helperGPUObj = await util.parsePlist(t, path.join(frameworksPath, `${opts.name} Helper (GPU).app`))
assertPlistStringValue(t, helperGPUObj, 'CFBundleName', opts.name, 'CFBundleName should reflect opts.name in helper app')
assertPlistStringValue(t, helperGPUObj, 'CFBundleName', `${opts.name} Helper (GPU)`, 'CFBundleName should reflect opts.name in helper app')
assertPlistStringValue(t, helperGPUObj, 'CFBundleExecutable', `${opts.name} Helper (GPU)`, 'CFBundleExecutable should reflect opts.name in helper app')
assertCFBundleIdentifierValue(t, helperGPUObj, helperBundleIdentifier, 'CFBundleIdentifier should reflect opts.helperBundleId, opts.appBundleId or fallback to default in helper app')
}

Expand Down