Skip to content

Commit

Permalink
Final fixes for the electron builder
Browse files Browse the repository at this point in the history
Fix for the "About" icon that weren't loading while being packaged in `app.asar` file.
  • Loading branch information
SpacingBat3 committed Oct 30, 2020
1 parent bedf391 commit 01f2042
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
17 changes: 9 additions & 8 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ const fs = require('fs')

// Get current app dir – also removes the need of importing icons manualy to the electron package dir.
var appDir = app.getAppPath()

// Check if we are using the packaged version – fixes `fs` for electron packagers.
// Seems to break the electron, when it is using the same variable (so needed to specify the new one)
if (fs.existsSync(`${appDir}/resources/app.asar`)) {
var appFsDir = `${appDir}/resources/app.asar`
// Somehow specifying appFsDir fixes `fs`
var appFsDir = appDir
// Check if we are using the packaged version.
// Fix for "About" icon (that can't be loaded with the electron)
if (appDir.indexOf("app.asar") < 0) {
var appIconDir = `${appDir}/icons`
} else {
var appFsDir = appDir
var appIconDir = process.resourcesPath
}

console.log(appDir.indexOf("app.asar"))
// Read properties from package.json
var packageJson = require(`${appDir}/package.json`)

Expand All @@ -34,7 +35,7 @@ function loadTranslations() {
// Vars to modify app behavior
var appName = 'Discord'
var appURL = 'https://discord.com/app'
var appIcon = `${appDir}/icons/app.png`
var appIcon = `${appIconDir}/app.png`
var appTrayIcon = `${appDir}/icons/tray.png`
var appTrayIconSmall = `${appDir}/icons/tray-small.png`
var winWidth = 1000
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@
]
},
"category": "Network"
}
},
"extraResources": [
{"from":"icons/app.png","to":"app.png"}
],
"extraFiles": [
"LICENSE.md"
]
},
"devDependencies": {
"electron": "^10.1.5",
Expand Down

0 comments on commit 01f2042

Please sign in to comment.