refactor: make name a prop on app (#17701)

Update app.name to be a property on app.
This commit is contained in:
Shelley Vohr 2019-04-30 13:55:33 -07:00 committed by GitHub
parent f2d41b7812
commit 8d83518f9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 57 additions and 25 deletions

View file

@ -56,8 +56,8 @@ app.isPackaged = (() => {
app._setDefaultAppPaths = (packagePath) => {
// Set the user path according to application's name.
app.setPath('userData', path.join(app.getPath('appData'), app.getName()))
app.setPath('userCache', path.join(app.getPath('cache'), app.getName()))
app.setPath('userData', path.join(app.getPath('appData'), app.name!))
app.setPath('userCache', path.join(app.getPath('cache'), app.name!))
app.setAppPath(packagePath)
// Add support for --user-data-dir=
@ -89,6 +89,7 @@ for (const name of events) {
// Property Deprecations
deprecate.fnToProperty(app, 'accessibilitySupportEnabled', '_isAccessibilitySupportEnabled', '_setAccessibilitySupportEnabled')
deprecate.fnToProperty(app, 'badgeCount', '_getBadgeCount', '_setBadgeCount')
deprecate.fnToProperty(app, 'name', '_getName', '_setName')
// Wrappers for native classes.
const { DownloadItem } = process.electronBinding('download_item')

View file

@ -9,7 +9,7 @@ const isLinux = process.platform === 'linux'
const roles = {
about: {
get label () {
return isLinux ? 'About' : `About ${app.getName()}`
return isLinux ? 'About' : `About ${app.name}`
}
},
close: {
@ -49,7 +49,7 @@ const roles = {
},
hide: {
get label () {
return `Hide ${app.getName()}`
return `Hide ${app.name}`
},
accelerator: 'Command+H'
},
@ -77,7 +77,7 @@ const roles = {
quit: {
get label () {
switch (process.platform) {
case 'darwin': return `Quit ${app.getName()}`
case 'darwin': return `Quit ${app.name}`
case 'win32': return 'Exit'
default: return 'Quit'
}
@ -172,7 +172,7 @@ const roles = {
// App submenu should be used for Mac only
appmenu: {
get label () {
return app.getName()
return app.name
},
submenu: [
{ role: 'about' },

View file

@ -14,7 +14,7 @@ const getTempDirectory = function () {
}
exports.crashReporterInit = function (options) {
const productName = options.productName || app.getName()
const productName = options.productName || app.name
const crashesDirectory = path.join(getTempDirectory(), `${productName} Crashes`)
let crashServicePid

View file

@ -134,16 +134,16 @@ if (packageJson.version != null) {
// Set application's name.
if (packageJson.productName != null) {
app.setName(`${packageJson.productName}`.trim())
app.name = `${packageJson.productName}`.trim()
} else if (packageJson.name != null) {
app.setName(`${packageJson.name}`.trim())
app.name = `${packageJson.name}`.trim()
}
// Set application's desktop name.
if (packageJson.desktopName != null) {
app.setDesktopName(packageJson.desktopName)
} else {
app.setDesktopName((app.getName()) + '.desktop')
app.setDesktopName(`${app.name}.desktop`)
}
// Set v8 flags