From 1112da24420ae4e7c02e23e8d0e5141039ed620b Mon Sep 17 00:00:00 2001 From: kylon <3252255+kylon@users.noreply.github.com> Date: Thu, 23 Feb 2023 14:04:55 +0100 Subject: [PATCH] make isAppPackage check more generic --- preload.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/preload.js b/preload.js index 691fb90..52f1a12 100644 --- a/preload.js +++ b/preload.js @@ -26,6 +26,7 @@ if (isMacOS) process.env.PATH = ['./node_modules/.bin', '/usr/local/bin', '/opt/homebrew/bin', process.env.PATH].join(':'); const SharedownAPI = (() => { + const _isAppPackage = __dirname.toLowerCase().includes('app.asar'); const _LoginModule = require('./sharedown/loginModules/loginModule'); const _path = require('node:path'); const _fs = require('node:fs'); @@ -144,20 +145,12 @@ const SharedownAPI = (() => { return false; } - function _isAppPackage(cwd) { - return process.env.hasOwnProperty('PORTABLE_EXECUTABLE_DIR') || - process.env.hasOwnProperty('APPDIR') || - (isWindows && cwd.includes('AppData\\Local\\Programs')) || - (isWindows && cwd.includes('C:\\Program Files\\sharedown')) || - (isMacOS && __dirname.toLowerCase().endsWith('app.asar')); - } - function _getPuppeteerExecutablePath() { const basePath = process.cwd(); let chromeDirPath = '/node_modules/puppeteer/chrome'; let ret = ''; - if (_isAppPackage(basePath)) { + if (_isAppPackage) { const pkgBasePath = isWindows ? basePath : (isMacOS ? __dirname : process.env.APPDIR); if (isMacOS)