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

This commit is contained in:
Daniel Scalzi 2018-04-28 18:07:39 -04:00
parent 95afe5c63a
commit f1cf433ca8
No known key found for this signature in database
GPG Key ID: 5CA2F145B63535F9
4 changed files with 19 additions and 3 deletions

View File

@ -28,6 +28,7 @@ const child_process = require('child_process')
const crypto = require('crypto') const crypto = require('crypto')
const EventEmitter = require('events') const EventEmitter = require('events')
const fs = require('fs') const fs = require('fs')
const isDev = require('electron-is-dev')
const mkpath = require('mkdirp'); const mkpath = require('mkdirp');
const path = require('path') const path = require('path')
const Registry = require('winreg') const Registry = require('winreg')
@ -464,7 +465,17 @@ class AssetGuard extends EventEmitter {
*/ */
static _extractPackXZ(filePaths, javaExecutable){ static _extractPackXZ(filePaths, javaExecutable){
return new Promise(function(fulfill, reject){ 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 filePath = filePaths.join(',')
const child = child_process.spawn(javaExecutable, ['-jar', libPath, '-packxz', filePath]) const child = child_process.spawn(javaExecutable, ['-jar', libPath, '-packxz', filePath])
child.stdout.on('data', (data) => { child.stdout.on('data', (data) => {

View File

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

View File

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