Skip to content

Commit

Permalink
fix(node) Electron apps crashing (#367)
Browse files Browse the repository at this point in the history
Inside a `app.asar` file, the package.json might get trimmed and the `bugs_url` might be missing

`repo_url` conditional check was added for good measure

* fix(node) resolve `bugs_url` from repo_url
  • Loading branch information
Araxeus authored Mar 22, 2023
1 parent 1c72a41 commit e7eacd9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/platform/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const is_cjs = !meta_url;
const __dirname__ = is_cjs ? __dirname : path.dirname(fileURLToPath(meta_url));

const package_json = JSON.parse(readFileSync(path.resolve(__dirname__, is_cjs ? '../package.json' : '../../package.json'), 'utf-8'));
const repo_url = package_json.homepage?.split('#')[0];

class Cache implements ICache {
#persistent_directory: string;
Expand Down Expand Up @@ -102,8 +103,8 @@ Platform.load({
runtime: 'node',
info: {
version: package_json.version,
bugs_url: package_json.bugs.url,
repo_url: package_json.homepage.split('#')[0]
bugs_url: package_json.bugs?.url || `${repo_url}/issues`,
repo_url
},
server: true,
Cache: Cache,
Expand All @@ -130,4 +131,4 @@ Platform.load({

export * from './lib.js';
import Innertube from './lib.js';
export default Innertube;
export default Innertube;

0 comments on commit e7eacd9

Please sign in to comment.