From b99c27cdc3ddb522a6566b92fdee10ee437ee9b0 Mon Sep 17 00:00:00 2001 From: Syl Date: Mon, 4 Mar 2024 18:50:22 -0600 Subject: [PATCH] bandage the settings error --- util/currentVersion/pybridge.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/util/currentVersion/pybridge.js b/util/currentVersion/pybridge.js index a24302c..ddc7ca6 100644 --- a/util/currentVersion/pybridge.js +++ b/util/currentVersion/pybridge.js @@ -40,16 +40,10 @@ module.exports = (forceCheck, getBuildDate, clear) => new Promise(async (res, re } }); });*/ - - child_process.execFile(path, [`--version-json`], { - env: { ...process.env, - PYBRIDGE_HEADER_SUPPORTED_SITES: `true`, - }, - }, (err, stdout, stderr) => { - if(err) return res(null) + const parse = (data) => new Promise(async (res, rej) => { try { - let version = JSON.parse((stdout ? stdout.toString('utf8').trim() : `` || stderr ? stderr.toString('utf8').trim() : ``)); + let version = JSON.parse(data); require(`../pythonBridge`).bridgeVersions = version; @@ -88,6 +82,20 @@ module.exports = (forceCheck, getBuildDate, clear) => new Promise(async (res, re rej(e); } }); + + child_process.execFile(path, [`--version-json`], { + env: { ...process.env, + PYBRIDGE_HEADER_SUPPORTED_SITES: `true`, + }, + }, (err, stdout, stderr) => { + parse(stdout ? stdout.toString('utf8').trim() : `` || stderr ? stderr.toString('utf8').trim() : ``).then(res).catch(e => { + child_process.execFile(path, [`--version-json`], (err, stdout, stderr) => { + parse(stdout ? stdout.toString('utf8').trim() : `` || stderr ? stderr.toString('utf8').trim() : ``).then(res).catch(e => { + return res(null); + }) + }); + }) + }); } else { console.log(`File doesn't exist, returning null`); return res(false)