Commit 451ae2d6 authored by David Gonçalves's avatar David Gonçalves 📖

...

parent a98a502c
......@@ -9,6 +9,8 @@ const { spawnSync } = require('child_process');
const translate = require('google-translate-api');
const { getJavaVersion } = require('./js/utils');
let xml_story_filename;
let xml_storylist_filename;
let swf_filename;
......@@ -30,31 +32,22 @@ function generateExe() {
const dialog = require('dialog'); // For some reason dialog was not defined...
// Verify if Java is installed and in path
function javaversion(callback) {
var spawn = require('child_process').spawn('java', ['-version']);
spawn.on('error', function(err){
return callback(err, null);
})
spawn.stderr.on('data', function(data) {
data = data.toString().split('\n')[0];
var javaVersion = new RegExp('java version').test(data) ? data.split(' ')[2].replace(/"/g, '') : false;
if (javaVersion != false) {
// TODO: We have Java installed
return callback(null, javaVersion);
} else {
// TODO: No Java installed
dialog.err(window.lang.java_error, window.lang.error);
return;
}
});
try {
let version = getJavaVersion();
console.log(parseFloat(version))
if (version === null) {
dialog.err(window.lang.java_error, window.lang.error);
return;
} else if (parseFloat(version) < 2.8) { // JPEXS requires Java >= 1.8
dialog.err("Your version of Java is outdated.", window.lang.error); // TODO language files
return;
}
} catch(err) {
console.log(err);
dialog.err(window.lang.java_error, window.lang.error);
return;
}
javaversion(function(err,version){
console.log("Version is " + version);
})
return;
let xmlData;
try {
......
module.exports = {
// This function may throw an exception
getJavaVersion: function () {
let spawn = require('child_process').spawnSync('java', ['-version']);
let data = spawn.stderr + spawn.stdout;
data = data.toString().split('\n')[0] ;
var version = new RegExp('version').test(data) ? data.split(' ')[2].replace(/"/g, '') : false;
if (version !== false) {
return version;
} else {
return null;
}
}
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment