ソースを参照

Fixed issue where extraction library could not be run from asar.

Daniel Scalzi 7 年 前
コミット
f1cf433ca8

+ 12 - 1
app/assets/js/assetguard.js

@@ -28,6 +28,7 @@ const child_process = require('child_process')
 const crypto = require('crypto')
 const EventEmitter = require('events')
 const fs = require('fs')
+const isDev = require('electron-is-dev')
 const mkpath = require('mkdirp');
 const path = require('path')
 const Registry = require('winreg')
@@ -464,7 +465,17 @@ class AssetGuard extends EventEmitter {
      */
     static _extractPackXZ(filePaths, javaExecutable){
         return new Promise(function(fulfill, reject){
-            const libPath = path.join(__dirname, '..', 'libraries', 'java', 'PackXZExtract.jar')
+            let libPath
+            if(isDev){
+                libPath = path.join(process.cwd(), 'libraries', 'java', 'PackXZExtract.jar')
+            } else {
+                if(process.platform === 'darwin'){
+                    libPath = path.join(process.cwd(),'Contents', 'Resources', 'libraries', 'java', 'PackXZExtract.jar')
+                } else {
+                    libPath = path.join(process.cwd(), 'resources', 'libraries', 'java', 'PackXZExtract.jar')
+                }
+            }
+            
             const filePath = filePaths.join(',')
             const child = child_process.spawn(javaExecutable, ['-jar', libPath, '-packxz', filePath])
             child.stdout.on('data', (data) => {

+ 4 - 2
app/assets/js/scripts/uicore.js

@@ -50,8 +50,10 @@ if(!isDev){
             case 'error':
                 console.log('Error during update check..')
                 console.debug('Error Code:', info != null ? info.code : null)
-                if(err.code === 'ERR_UPDATER_INVALID_RELEASE_FEED'){
-                    console.log('No suitable releases found.')
+                if(err != null && err.code != null){
+                    if(err.code === 'ERR_UPDATER_INVALID_RELEASE_FEED'){
+                        console.log('No suitable releases found.')
+                    }
                 }
                 break
             default:

+ 0 - 0
app/assets/libraries/java/PackXZExtract.jar → libraries/java/PackXZExtract.jar


+ 3 - 0
package.json

@@ -95,6 +95,9 @@
     "files": [
       "!{target,logs,.vscode,docs,dev-app-update.yml}"
     ],
+    "extraResources": [
+      "libraries"
+    ],
     "asar": true
   }
 }