diff --git a/Jenkinsfile b/Jenkinsfile index 7621f77..3ab1ebd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,6 +13,9 @@ pipeline { sh 'cp -r javaCompiledReleaseWindows/Release out/pakkit-win32-x64/resources/app/node_modules/java/build/Release' sh 'npx electron-forge package --platform linux' sh 'cd out/pakkit-linux-x64/resources/app/; node-prune; npx electron-rebuild -v 8.5.2;' + sh 'mv out/pakkit-linux-x64/pakkit out/pakkit-linux-x64/dont_run_directly' + sh 'mv launch_linux_ci_builds.sh out/pakkit-linux-x64/pakkit' + sh 'chmod +x out/pakkit-linux-x64/pakkit' sh 'npx electron-forge package --platform darwin' sh 'cd out/pakkit-darwin-x64/pakkit.app/Contents/Resources/app/; npx electron-rebuild -v 8.5.2;' sh 'mv out/pakkit-win32-x64 pakkit-windows-x64' diff --git a/launch_linux_ci_builds.sh b/launch_linux_ci_builds.sh new file mode 100644 index 0000000..e20c15c --- /dev/null +++ b/launch_linux_ci_builds.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Hacky workaround for problems on Linux +chmod +x dont_run_directly +output="SHOULD RESTART PROGRAM" +while [[ $output == *"SHOULD RESTART PROGRAM"* ]]; do + if test -f "resources/app/node_modules/java/build/jvm_dll_path.json"; then + LD_LIBRARY_PATH=$(cat resources/app/node_modules/java/build/jvm_dll_path.json| sed 's/"//g' | sed 's/://g') ./dont_run_directly + output="" + else + exec 3>&1 + output=$(LD_LIBRARY_PATH=$(cat resources/app/node_modules/java/build/jvm_dll_path.json| sed 's/"//g' | sed 's/://g') ./dont_run_directly 2>&1 1>&3) + exec 3>&- + fi +done \ No newline at end of file diff --git a/src/index.js b/src/index.js index 22c4876..fe389e5 100644 --- a/src/index.js +++ b/src/index.js @@ -17,6 +17,8 @@ let setupDataFolder let continueProgram = true +// Hacky workaround for problems with java module in CI builds + try { javaProxy = require('./proxy/java/proxy.js') bedrockProxy = require('./proxy/bedrock/proxy.js') @@ -26,27 +28,31 @@ try { console.log('err', err.message) if (err.message.includes('The specified module could not be found.') || err.message.includes('Cannot find module')) { console.log('fix!!!') - if (!fs.existsSync(resourcesPath + 'flag_java_fixed.txt')) { - fs.openSync(resourcesPath + 'flag_java_fixed.txt', 'w') - // Run postInstall.js for java module - if (fs.existsSync(resourcesPath + 'node_modules/java/')) { - console.log('Running postInstall.js...') - const oldDir = process.cwd() - process.chdir(resourcesPath + 'node_modules/java/') - require(oldDir + '/' + resourcesPath + 'node_modules/java/postInstall.js') - process.chdir(oldDir) - - continueProgram = false - setTimeout(() => { + continueProgram = false + // Run postInstall.js for java module + if (fs.existsSync(resourcesPath + 'node_modules/java/')) { + console.log('Running postInstall.js...') + const oldDir = process.cwd() + process.chdir(resourcesPath + 'node_modules/java/') + require(oldDir + '/' + resourcesPath + 'node_modules/java/postInstall.js') + process.chdir(oldDir) + + if (process.platform !== 'win32') { + console.error('SHOULD RESTART PROGRAM') + } + + setTimeout(() => { + // Handled by start script on Linux + if (process.platform === 'win32') { app.relaunch() app.exit() - process.exit(0) - }, 3000) - } else { - console.error(resourcesPath + 'node_modules/java/ does not exist!') - app.exit() + } process.exit(0) - } + }, 3000) + } else { + console.error(resourcesPath + 'node_modules/java/ does not exist!') + app.exit() + process.exit(0) } } }