From f1cf433ca84cba6aafaad84ea2596dc6faa6473d Mon Sep 17 00:00:00 2001 From: Daniel Scalzi Date: Sat, 28 Apr 2018 18:07:39 -0400 Subject: [PATCH] Fixed issue where extraction library could not be run from asar. --- app/assets/js/assetguard.js | 13 ++++++++++++- app/assets/js/scripts/uicore.js | 6 ++++-- .../libraries => libraries}/java/PackXZExtract.jar | Bin package.json | 3 +++ 4 files changed, 19 insertions(+), 3 deletions(-) rename {app/assets/libraries => libraries}/java/PackXZExtract.jar (100%) diff --git a/app/assets/js/assetguard.js b/app/assets/js/assetguard.js index 4b3f0a1..97eeda5 100644 --- a/app/assets/js/assetguard.js +++ b/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) => { diff --git a/app/assets/js/scripts/uicore.js b/app/assets/js/scripts/uicore.js index 1e41c5f..2e2ae1c 100644 --- a/app/assets/js/scripts/uicore.js +++ b/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: diff --git a/app/assets/libraries/java/PackXZExtract.jar b/libraries/java/PackXZExtract.jar similarity index 100% rename from app/assets/libraries/java/PackXZExtract.jar rename to libraries/java/PackXZExtract.jar diff --git a/package.json b/package.json index 50f332f..6f9a076 100644 --- a/package.json +++ b/package.json @@ -95,6 +95,9 @@ "files": [ "!{target,logs,.vscode,docs,dev-app-update.yml}" ], + "extraResources": [ + "libraries" + ], "asar": true } }