From 6440455470904c905e2636df0ab461064f8377be Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Fri, 28 Jan 2022 18:08:01 +0530 Subject: [PATCH] fix: path fixes, electron-builder creds --- electron-builder.yml | 8 +++++++- src/contactMothership.js | 16 +++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/electron-builder.yml b/electron-builder.yml index 99f1ca38..da8830d4 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -1,6 +1,12 @@ productName: Frappe Books appId: io.frappe.books afterSign: build/notarize.js +extraResources: [ + { + from: 'err_log_creds.txt', + to: '../creds/err_log_creds.txt', + } +] mac: type: distribution category: public.app-category.finance @@ -36,4 +42,4 @@ linux: target: - deb - AppImage - - rpm \ No newline at end of file + - rpm diff --git a/src/contactMothership.js b/src/contactMothership.js index c1e9babf..e6d5938b 100644 --- a/src/contactMothership.js +++ b/src/contactMothership.js @@ -6,7 +6,18 @@ import path from 'path'; function getUrlAndTokenString() { const inProduction = app.isPackaged; - const errLogCredsPath = path.join(__dirname, '../err_log_creds.txt'); + let errLogCredsPath = path.join( + process.resourcesPath, + '../creds/err_log_creds.txt' + ); + if (!fs.existsSync(errLogCredsPath)) { + errLogCredsPath = path.join(__dirname, '../err_log_creds.txt'); + } + + if (!fs.existsSync(errLogCredsPath)) { + !inProduction && console.log(`${errLogCredsPath} doesn't exist, can't log`); + return; + } let apiKey, apiSecret, url; try { @@ -16,13 +27,12 @@ function getUrlAndTokenString() { .filter((f) => f.length); } catch (err) { if (!inProduction) { - console.log('error logging failed'); + console.log(`logging error using creds at: ${errLogCredsPath} failed`); console.log(err); } return; } - !inProduction && console.log(apiKey, apiSecret, url); return { url: encodeURI(url), tokenString: `token ${apiKey}:${apiSecret}` }; }